This may be a simple solution, but I can't figure it out.
I have a bunch of images sitting like this:
<div class='image-bar'>
<span>
<img class='my-image' src='blah1' id='1'>
</span>
<span>
<img class='my-image' src='blah2' id='2'>
</span>
<span>
<img class='my-image' src='blah3' id='3'>
</span>
</div>
Given the image id, I need to find the next and previous image using jQuery.
Using 2 as an example, I tried the following to get the following image:
$('.image-bar').find('.my-image[id="2"]').next();
I think that until the "attribute equals" selector is selected, but since the image with id 3 is not even marriage, the following () does not work. How can I handle this? Any pointers are welcome!
source
share