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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:02:46+00:00 2026-05-25T10:02:46+00:00

Does anyone know how to reset the styles of an element with jQuery? For

  • 0

Does anyone know how to reset the styles of an element with jQuery? For instance, I have a stylesheet like this:

.container-red {  background-color: #f00; }
.container-red #innerbox { background-color: #fff; }
.container-white { background-color: #fff; }
.container-white #innerbox { background-color: #f00; }
#innerbox { margin: 20px; }

And this markup:

<div id="container" class="container-red">
     <div id="innerbox">Some text here</div>
</div>

Then when I change the class using jQuery

$("#container").removeClass("container-red").addClass("container-white");

the innerbox styling does not change to match, since it has already been styled, which leaves me with a white container and a white inner box, rather than a white container and a red inner box. Therefore, I want to be able to do something like

$("#container").children().resetStyles();

and have each of the containers children update to the correct styling

EDIT: Sorry, you’re all right, the code does work fine, my problem was simply that I had some other css overriding my class styling.

  • 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-25T10:02:47+00:00Added an answer on May 25, 2026 at 10:02 am

    You are doing something wrong i think because i tested it and to me it works:

    http://jsfiddle.net/VH4du/

    I tested it on chrome, firefox and IE9.

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

Sidebar

Related Questions

Does anyone know how to reset the instance variables via a class method. Something
Does anyone know is it possible for me to reset/remove the session for php
I'm trying to force PreferenceActivity to refresh. Does anyone know how to do this?
Does anyone know how to clear a jQuery tmpl() so I can re-populate it?
Does anyone know how to get the jQuery .load() function to work concurrently? Right
Does anyone know how to reset the border color of an input control once
Does anyone know if (and how) I can build an application (Java/Ruby/whatever) doing REST
Does anyone know of a Twitter service proxy in particular, or a general-purpose REST
Does anyone know how to get IntelliSense to work reliably when working in C/C++
Does anyone know how to transform a enum value to a human readable value?

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.