Jump to content

Jquery iterate through li a


noober

Recommended Posts

This is my setup:

 

<div class="item-list">
    <ul>
        <li class="first"><a href="/retailers# " id="Item1" class="Item1 inactive active">Item 1</a></li> 
        <li><a href="/retailers# " id="Item2" class="Item2 inactive">Item 2</a></li> 
        <li class="last"><a href="/retailers# " id="Item3" class="Item3 inactive">Item 3</a></li> 
    </ul>
</div>  
</div> 

 

My thoughts were to add the active class to the next anchor tag onclick, then remove the active class from the original element. My problem is that next apparently doesn't work, or I'm using it wrong. Using children and siblings don't seem to do anything either because I'm attempting to go through the classes in the li a, instead of the usual li tag itself. Any ideas of how I would iterate through without changing my html? Thanks.

 

I test out selecting the next element with the below, though it doesn't work.

 

$('.inactive.active').next('.inactive').css('border', '3px solid blue');

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/227480-jquery-iterate-through-li-a/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.