Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6840853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:53:42+00:00 2026-05-26T23:53:42+00:00

I am trying to use a next image link to select the next tag

  • 0

I am trying to use a next image link to select the next tag in a list of elements and add a class to the element when it is clicked. I would also like to remove the class from the previous tag aswell. I have tried using the .next(‘a’) selector and also the .nextAll(‘a:first’), but cannot seem to get it to work at all. I have also tried to select the next ‘NavigationItem’.

My code is as follows:

        <div id="navigation">
            <ul>
                <li><a class="navSelected NavigationItem" href="#" >Section 1</a><span>ben</span></li>
                <li><a class="NavigationItem" href="#" >Section 2</a><span>ben</span></li>
                <li><a class="NavigationItem" href="#" >Section 3</a><span>ben</span></li>
                <li><a class="NavigationItem" href="#" >Section 4</a><span>ben</span></li>
                <li><a class="NavigationItem" href="#" >Section 5</a><span>ben</span></li>
            </ul>
        </div>

  <img class="prev" src="img/prev.gif" alt="prev" width="42" height="53" />
  <img class="next" src="img/next.gif" alt="next" width="42" height="53" />

and the jQuery:

        $('.next').click(function(){
                $('a.navSelected').nextAll('a:first').addClass('navSelected');
                $('.NavigationItem').removeClass('navSelected');

        });

I am also trying to do the reverse for the previous button, but cant seem to get that working either.

Thanks for your time, any help would be greatly apprecitated.

Simon

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:53:43+00:00Added an answer on May 26, 2026 at 11:53 pm
    $('.next').click(function() {
        $('#navigation li a.navSelected').removeClass('navSelected')
            .parent().next().find('a.NavigationItem').addClass('navSelected');
    });
    

    Code: http://jsfiddle.net/UQwn9/1/

    Or if you need to swich to first on the last element:

    $('.next').click(function() {
        var $el = $('#navigation li a.navSelected').removeClass('navSelected');
        var $next = $el.parent().next();
    
        if ($next.length == 0)
            $next = $('#navigation li:first');
    
        $next.find('a.NavigationItem').addClass('navSelected');
    });
    

    Code: http://jsfiddle.net/UQwn9/2/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to use an excpetion class which could provide location reference for XML parsing,
I am trying to use the code below to select all values of notableWork,
My problem is the next: I am trying resize a image size depending a
I'm trying to delete an image file whenever a user clicks a link to
Sorry guys, I am trying to add an event to a image inside of
trying to use this function http://php.net/manual/en/function.strip-tags.php against this: [link-code-html] => <a href=http://www.kqzyfj.com/click-3782261-10563989>invisibleSHIELD for the
I'm trying to create a simple interactive image map where the user would be
I'm trying to remove the first link-image below the h4 and prepend it to
I'm looking to use a blank div element to display a background image but
I was trying use a set of filter functions to run the appropriate routine,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.