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

  • Home
  • SEARCH
  • 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 613913
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:03:18+00:00 2026-05-13T18:03:18+00:00

The easiest way to see the problem is checking the code here: http://www.studioimbrue.com/beta What

  • 0

The easiest way to see the problem is checking the code here: http://www.studioimbrue.com/beta

What I need to do is once a thumbnail is clicked, to removed the “selected” class from all other thumbnails that are in this same or without removing them from the other galleries on the page. Right now, I have everything working except the class removal. Someone helped me in another question but wasn’t quite specific enough (my javascript skills aren’t all that great!) I’m using jQuery. Thanks for the help.

Well in that case, I’m not sure why this doesn’t work properly:

$(document).ready(function(){ 
    var activeOpacity   = 1.0,
        inactiveOpacity = 0.6,
        fadeTime = 100,
        clickedClass = "selected",
        thumbs = ".thumbscontainer ul li img";

    $(thumbs).fadeTo(1, inactiveOpacity);

    $(thumbs).hover(
        function(){
            $(this).fadeTo(fadeTime, activeOpacity);
        },
        function(){
            // Only fade out if the user hasn't clicked the thumb
            if(!$(this).hasClass(clickedClass)) {
                $(this).fadeTo(fadeTime, inactiveOpacity);
            }
        });
     $(thumbs).click(function() {
         // Remove selected class from any elements other than this
         var previous = $(thumbs+'.'+clickedClass).eq();
         var clicked = $(this);
         if(clicked !== previous) {
             previous.removeClass(clickedClass);
         }
         clicked.addClass(clickedClass).fadeTo(fadeTime, activeOpacity);
     });
});
  • 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-13T18:03:18+00:00Added an answer on May 13, 2026 at 6:03 pm

    I see you’re using jQuery (and have edited your question accordingly).

    With jQuery, it’s really easy to get a list of matching elements using CSS syntax:

    var list = $('#parentId > .selected');
    

    That gets a list of the direct children of the element with the ID “parentId” that have the class “selected”. You can then do things with them, such as:

    list.removeClass("selected");
    

    Then add “selected” to the element you want to select.

    Edit I think this should do it:

    $(thumbs).click(function() {
         // Remove selected class from any elements other than this
         var clicked, previous;
         clicked = $(this);
         if (!clicked.hasClass(clickedClass)) {
             previous = $(thumbs+'.'+clickedClass);
             previous.removeClass(clickedClass).fadeTo(fadeTime, inactiveOpacity);
             clicked.addClass(clickedClass).fadeTo(fadeTime, activeOpacity);
         }
     });
    

    I’m assuming there that the “selected” class isn’t necessary for the fade effect to look right.

    Note how the above will completely ignore the click if the clicked element already has the class. If you don’t want that, remove the hasClass check and add .not(clicked) to the end of the previous = $(thumbs+'.'+clickedClass) line, but I don’t know what your fade in would do at that point if you’ve already done it once.

    I’m not getting the hover stuff; I thought you wanted this to happen on click, not hover.

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

Sidebar

Related Questions

The easiest way to explain this problem is to show you some code: Public
The easiest way to see this problem will be to run the sample project
What's the easiest way to get RPC in .NET? I see that there is
I have a problem with my image animation frame. The easiest way to show
I'm trying to test a gateway I wrote(see What's the easiest way to test
What's the easiest way to see how many users are currently online on my
The easiest way to explain my question may be with an example, so let
What's the easiest way to search a div for a text string using jquery?
What would be the easiest way to convert the following key->value object array to
Which is the easiest way to validate a file and to prevend changing it's

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.