[SOLVED] Traversing Children
Hi!
I need to traverse some HTML to change some css properties, but can´t seem to get the right element! I think Im having some problems understanding the children() function..
Here is the HTML code:
-
<div class="student">
<div class="title"></div>
<div class="name"></div>
<div class="course"></div>
<div class="contact"></div>
<div class="text"></div>
<div class="slide" style="position: absolute; top: 365px;">
<a href="#" class="I NEED TO CHANGE THIS ONE">
more
</a>
</div>
</div>
<div class="picture">
<a href="#" class="FROM THIS ONE"><img src="..." /></a>
</div>
<div class="pictunder"></div>
<div class="clear"></div>
</div>
So i need to change a CSS property of "<a href="#" class="I NEED TO CHANGE THIS ONE"> " when I click "<a href="#" class="FROM THIS ONE"><img src="..." /></a>"
So far I have this JS code:
-
$('.FROM THIS ONE').toggle(function(){
$(this).parent().prev().children('slide').children('.I NEED TO CHANGE THIS ONE').css({ backgroundImage : "url(img/hide-project.png)" });
}, function () {
$(this).parent().prev().children('slide').children('.I NEED TO CHANGE THIS ONE').css({ backgroundImage : "url(img/show-project.png)" });
});
And that isnt working. Im pretty sure that the problem lies in the traversal, but i cant get it working! I have to use relative traversing because there will be many "student" divs.