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 6038345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T06:12:22+00:00 2026-05-23T06:12:22+00:00

I am a total jQuery newbie (well web coding newbie come to that) and

  • 0

I am a total jQuery newbie (well web coding newbie come to that) and am excited about how much you can do so easily. I’m totally stuck on this though and would appreciate any help.

I have a ul with a list of colour swatches. I then filter these by showing and hiding. When hovering over one swatch I need to change the Class of the next sibling swatch that’s visible. This achieves it until I hide anything:

$('+ li', this).toggleClass('swatchroll-sister');

As does this

$(this).next().toggleClass('swatchroll-sister');

However once stuff is hidden these then change the class of the hidden elements, rather than the next visible one. I think the :visible selector is what I need but I’ve tried putting it everywhere and can’t get it to work. Some things I’ve tried:

$('+ li:visible', this).next().toggleClass('swatchroll-sister');
$(this).next('li:visible').toggleClass('swatchroll-sister');
$('+ li', this).toggleClass('swatchroll-sister');
$('+ li', this).('item:visible').toggleClass('swatchroll-sister');

So my question is probably “Where do I put the :Visible selector?” but maybe that’s the wrong approach to start with? Thanks for any pointers.

  • 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-23T06:12:23+00:00Added an answer on May 23, 2026 at 6:12 am

    Without seeing your exact code, I can only suggest something like:

    $('li').click(
        function(){
            var i = $(this).index('li:visible');
            var nextVisible = $(this).closest('ul').find('li:visible').eq(i+1);
            $(nextVisible).addClass('classNameToAdd');
        });
    

    JS Fiddle demo.

    Notice the selector passed to the index() method, which finds the index of the current element among the elements returned by the selector, in this case the li:visible.

    References:

    • index().
    • eq().
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm a total newbie when it comes to Javascript/jQuery so hopefully you can help
Total beginner question about jQuery: I have a Form that contains several TextBoxes (input
I'll preface this by saying that I'm a total jquery newbie. That said, I'd
I couldn't find anything about getting the total JSON record count using jQuery. Here
How to find total number textbox present in a web form using Jquery?
So, I am a TOTAL jQuery / jQuery Tools newbie, but I'm learning... Here's
Just wondering - how using jQuery - I can get an elements formatted total
I’m adding a total amount value to a DIV through a jQuery Ajax call
Here the total height of all <div> 's are 900 pixels, but the jQuery
Total newbie question but this is driving me mad! I'm trying this: myInt =

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.