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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.