Reputation: 7969
I've been having trouble hashing out a selector for the image inside this mess of code below. Originally thought $('img.gallery')[0];
would work, but it doesn't.. also tried $('img.advance-link')
and $('.gallery').find(img)[0];
Thanks for your help!
JS Fiddle: http://jsfiddle.net/danielredwood/UfGrM/
HTML:
<div class="gallery front">
<span class="image-wrapper current">
<a class="advance-link" rel="history" href="#1" title="Title #10">
<img alt="Title #10" src="../img/10.jpeg">
</a>
</span>
</div>
Upvotes: 1
Views: 2121
Reputation: 1585
$('.gallery .image-wrapper .advance-link img').css('border', '10px solid black');
Just use it like a CSS Selector.
This reads like search for every image contained by a advance-link wich in turn must be contained by a image-wrapper wich must be inside a gallery.
When you want access the jQuery result, please consider:
Upvotes: 1
Reputation: 60413
$('img.gallery')
your image doesnt have the class gallery
one of its parents does.
$('img.advance-link')
your image doesnt have the class advance-link
its parent does.
You would need $('.gallery img')
or $('.advance-link img')
.
Upvotes: 0
Reputation: 30135
with that construct there are many possibilities to access the image:
which range from quick and easy
$('.advance-link>img')
to rather complex but very specific (only for illustration :) )
$('div.gallery.front>span.image-wrapper.current>a.advance-link>img')
Upvotes: 1