jQuery get prev or next item from selected
I have this list of thumbs
<ul>
<li class=thumb></li>
<li class=thumb chosen></li>
<li class=thumb></li>
<li class=thumb></li>
</ul>
I also have navigation arrows, prev and next with classes 'next-image' and
'prev-image'. When i click on the navigation arrow i want to trigger click
event on the prev or next thumb.
How can i target the previous or next thumb, from the thumb with class
chosen.
$('.prev-image').click( function() {
$('.thumb.chosen').prev().trigger('click');
});
$('.next-image').click( function() {
$('.thumb.chosen').next().trigger('click');
});
This way it will search for following sibling with class chosen, but i
need it to search the prev or next thumb from the thumb with class chosen.
No comments:
Post a Comment