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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:43:13+00:00 2026-05-25T23:43:13+00:00

I want to be able to remove/change the internal style sheets values through JavasScript.

  • 0

I want to be able to remove/change the internal style sheets values through JavasScript. It has to be through JS because I cannot edit the html since I am using an application that does not allow me to, but I can use JS. How can I change the value for the background or remove it completely? Or is there another way to accomplish this?

<body>
<head>
  <style type="text/css">
  #company-header{background:#000 !important;}
  </style>
</head>

<div id="company-header"></div>
</body>
  • 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-25T23:43:14+00:00Added an answer on May 25, 2026 at 11:43 pm

    If your just going to change small bits of css, using jQuery’s css() is your best option, but it does not always recognize !important, for that you would probably need cssText, like this:

    $('#id').css('cssText', 'height: 200px !important');
    

    This replaces all the css, so everything needs to be defined in the new css rules that are added.

    If you are changing a lot of css, or just want to make it easier for the next time, you could remove all inline css and add an external stylesheet instead.

    To remove all inline styles you would do something like this:

    $(document).removeAttr('style');
    

    or for div’s only

    $('div').removeAttr('style');
    

    Depending on how many styles there are, this could take som time to process.

    Then to add a new stylesheet do:

    (function() {
        var myCSS = document.createElement('link');
        myCSS.rel = 'stylesheet';
        myCSS.type = 'text/css';
        myCSS.src = '/styles/mystylesheet.css';
        var place = document.getElementsByTagName('script')[0];
        place.parentNode.insertBefore(myCSS, place);
    })();
    

    Edit:

    function removeCSS() {
        var badCSS = document.getElementsByTagName('style')[0];
            $(badCSS).remove();     
    });
    

    This will remove all the markup in the internal stylesheet, but since the styles are already loaded it will make absolutely no difference.

    Internal styles will always override external styles, but for one exeption, if the external style is !important. If both the external and internal styles are !important, the internal style will be used.

    Loading an external stylesheet dynamicly with javascript will only work if everything you are trying to override is set to !important in the external stylesheet, and not set to !important in the internal stylesheet.

    Changing the styles directly in the DOM with jQuery’s css() and using the cssText option to override the !important set in the internal stylesheet may be your only viable option if there is absolutely no way to alter the html file and remove the internal stylesheet.

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

Sidebar

Related Questions

So I want to be able to add/remove class methods at runtime. Before you
I have the following code. I want to add/remove check-box values to an array
I have a list that I want to be able to store 20 values.
I want to be able to retrieve a remote image from a webserver, resample
I'm using LaTeX and BibTeX for an article, and I want to able to
Want to be able to provide a search interface for a collection of objects
I want to be able to capture the exception that is thrown when a
I want to be able to do: For Each thing In things End For
I want to be able to play sound files in my program. Where should
I want to be able to make an HTTP call updating some select boxes

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.