How to change style attribut?
Hi everybody,
Im trying to change a style attribut by jquery but can't get it work.
I have a list of images like that:
- <div id="bgstrecher" class="bgstrecher">
- <ul>
- <li class="landscapes bgs-current" style="display:list-item"><img src="path img 1" /></li>
- <li class="landscapes" style="display:none"><img src="path img 2" /></li>
- <li class="landscapes" style="display:none"><img src="path img 3" /></li>
- <li class="landscapes" style="display:none"><img src="path img 4" /></li>
- <ul>
- </div>
I created another list. When I click on one element I get the value (<a>value here</a>) which is the same as one of the link (link1, link 2, link 3, link 4 etc). And then I would like to change the style of the li who has the same path as the clicked element.
- <div id="pagination">
- <a class="pagination">path img 1</a>
- <a class="pagination">path img 2</a>
- <a class="pagination">path img 3</a>
- <a class="pagination">path img 4</a>
- </div>
My script:
- $('#pagination a').live("click", function(){
- linkvalue = $(this).text();
- alert("link : " + linkvalue);
-
- $('#bgstretcher li img').each(function(index) {
- alert(index + ': ' + $(this).attr("src"));
-
- if ($(this).attr("src") == linkvalue ) {
- alert ("found");
- }
- });
- });
Do you have any ideas how to make it work?
Regards