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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:54:08+00:00 2026-06-09T06:54:08+00:00

I have this HTML: <body> <div id=switcher class=switcher> <h3>Style Switcher</h3> <button id=switcher-default> Default </button>

  • 0

I have this HTML:

<body>
    <div id="switcher" class="switcher">
        <h3>Style Switcher</h3>
        <button id="switcher-default">
                Default
        </button>
        <button id="switcher-narrow">
            Narrow Column
        </button>
        <button id="switcher-large">
            Large Print
        </button>
    </div>
    <p>asdfasdfasdfas dsadf</p>
    <p>asd'lfkasdf</p>

    <script src="jquery.js"></script>
    <script src="test.js"></script>
</body>

I want to add a class to all body elements except my first div (which has the id called switcher), when I click on the Large print button.

I have tried

 $(document).ready(function(){
   $("#switcher-large").bind("click", function(){       
    $("body:not(:first-child)").addClass("large");      
    });
});

and

$(document).ready(function(){
   $("#switcher-large").bind("click", function(){       
    $("body:not(div)").addClass("large");       
    });
});

and

$(document).ready(function(){
       $("#switcher-large").bind("click", function(){       
        $("body").not("#switcher").addClass("large");       
        });
    });

but none seem to work (the class applies to all elements).

I don’t want to find an alternate way like selecting only p elements. I just want to understand why the selectors I used don’t work…

  • 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-06-09T06:54:10+00:00Added an answer on June 9, 2026 at 6:54 am

    You need to exclude the document.body itself. Like

    $("body *").not("#switcher").addClass("large"); 
    

    This will query for all children of body, excluding #switcher. Maybe more convinient:

    $(document.body).contents().not('#switcher').addClass('large');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: <html> <body> <div style=background-color: lightblue; onClick=alert(myArray[0][1])> this is a
I have this HTML structure <div class=buttons> <button data-icon=ui-icon-disk class=save>Save1</button> <button data-icon=ui-icon-check class=ok>OK1</button> <button
I have this html code: <body> <div class=CodeRay> <div class=code><pre><span class=no> 1</span> require <span
If I have this HTML <div class=comment-body> [img]http://topnews.net.nz/images/YouTube-3.jpg[/img] random text here </div> <div class=comment-body>
I have this HTML code: <body> <div id=div0 style=display:inline; background-color:green; width:100%> <div id=div1 style=display:inline;
I have a div directly under the body. My HTML looks like this: <body>
I have just normalized the font size with this: html, body, div, span, applet,
I have this HTML: <html> <body> <div id=pgContent> <div id=studyOverlay> <div id=studyContainer> <div id=studyTest>
For example I have this HTML: <body> <div>Text</div> </body> And I would like to
i have this HTML page <html> <body> <div>a</div> <div>b</div> <div>c</div> <div>d</div> <div id='in_or_out'>e</div> <div>f</div>

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.