For example, I have this HTML structure:
<ul>
<li><a class="ac_list_a">some text</a></li>
<li><a class="ac_list_a">some text</a></li>
<li><a class="ac_list_a">some text</a></li>
<li><a class="ac_list_a ac_current_a">some text</a></li>
<li><a class="ac_list_a">some text</a></li>
<li><a class="ac_list_a">some text</a></li>
</ul>
I need to get the next or previous ac_list_a from ac_current_a.
I have tried to do like this:
var all_a = $('.ac_list_a,.ac_current_a').eq('.ac_current_a').next();
But it doesn’t work.
How would you solve it?
Update
That is, of course I can do it the dumb way, by assigning class to all li elemnts, then using
parents(class).next().find(a.class)
But is it possible to do it more dynamic way? Because the structure of HTML could change in the future.
eqtakes an integer index for a function, not a selector. You can use theindexfunction to find that index, however, and then useeq.