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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:31:55+00:00 2026-05-26T05:31:55+00:00

I have a div structure like this [simple menu]: <div class=float menuA> <div class=float

  • 0

I have a div structure like this [simple menu]:

<div class="float menuA">
    <div class="float selected"></div>
    <div class="float default"></div>
    <div class="float default"></div>
    <div class="float default"></div>

    <div class="clear"></div>
</div>

When I click on any div with a classname of “default” I would like to:

  1. Use .removeClass().addClass() to swap the class called “selected” to “default”
  2. Update the recently clicked div (with class==”default”) to class==”selected”

This approach works fine when the class tags contain exactly ONE classname (for example: class=”default” and class=”selected”) but when there is a space seperated list of classnames within a single class tag, things dont go so smoothly.

Question:
How do I find the element with class==”selected” when there are multiple classnames within a single tag?

Any help appreciated guys….

  • 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-26T05:31:55+00:00Added an answer on May 26, 2026 at 5:31 am

    It looks like you’re trying to make a navigation menu. The easiest way to do this is:

    $(function() {
        $('div.menuA div.float').click(function() {
            $(this).siblings('.selected').removeClass('selected').addClass('default');
            $(this).removeClass('default').addClass('selected');
        });
    });
    

    This doesn’t directly answer your question though. In order to ‘find’ an element that’s a child of another element, use the find() method:

    // finds all divs with class 'selected' in the div.menuA div
    $('div.menuA').find('.selected');
    

    And if you want to skip the extra find() call, you can just concatenate the dots together:

    // selects divs with the classes 'selected' and 'default'
    $('div.menuA div.selected.default'); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a html structure like this: <div class=one> <div id=two> <h2>Any</h2> <h4>Any</h4> </div>
i have html structure like this <div> <span class=ic> <span class=ic>12345</span> </span> </div> i
Ok, I have a structure like this: <div class=image> <img src=img1.jpg alt= /> </div>
Ok, so i have a HTML structure like this: <div class=content> <div id=a1 class=article>
I usually have my structure laid out something like this: <div id=all> <div id=page>
If I have a structure like this: <div id=main> <div id=sidebar> <div id=tag-cloud/> </div>
I have a structure of div s inside div s, something like this: <div
I have a structure like this <div id=first> <div id=second> <div id=third> <div id=fourth>
I have a simple div on html, something like: <div class=warning> <h3>Please make sure:</h3>
I have a menu structure like this: * Alpina o Jongensfietsen o Meisjesfietsen *

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.