how to replace entire css text with another?

Tags: javascript,jquery,css,coding-style,stylesheet

Problem :

I have web page with different styles that the user can change and build on the fly. I have this code working with browsers IE-9+,chrome,FF,safari.


$("#customCss").text(css_txt );
$('head').append('<style type="text/css" id="customCss"> ' + css_txt + '</style>');

I want to fit the site to IE-7,8. But this code not working with IE-7,8. I am getting this error code:

Microsoft JScript runtime error: Unexpected call to method or property access.

in this jquery func jquery :

append: function () {
            return this.domManip(arguments, true, function (elem) {
                if (this.nodeType === 1) {

I have try this also with no luck :


any idea why?

Solution :

Store a reference to the link tag and then modify the href to the new script if it's an external script. If it's internal, try removing the old one with .remove() and .append() a new one right after the <body>.

    CSS Howto..

    CSHTML - How to I make the unordered list items horizontal?

    How do I use CSS to add a non-rectangular border around an image?

    CSS: How to align buttons and text horizontally

    how can bring to front clicked div in jquery?

    ExtJS how to set button css by using pressedCls config

    jquery - how to change the display css attribute of a button within a li on hover

    How to run CSS text animation in a sequence. (one line of text after another)

    How to change 1 out of a menu/model thing with css instead of a whole model/menu?

    A really simple question: How to apply a style to an iframe whose parent tag's id is known?

    How to create generic CSS class with input parameter

    How to attach an element on the dynamically created div

    How do I set frame alignment?

    How does a CSS rule override another CSS rule?

    How to make accessible h1 with logo

    How to select that has no “type” with CSS

    How to force style HTML element?

    how to set css and html in textarea [closed]

    how to stick the footer to the bottom of the page while moving it upward in a parallax-like effect?

    Showing Text When Hovering Over an Image Link

    How to link to a “tab” on my website

    How can I have my cards stack on top of one another?

    How to create and apply CSS to javascript Alert

    How to Override CSS class?

    How to change the css style for phone and desktop?

    How to force thumbnails to overflow right and not below

    How to change the content of a span using css hover?

    How to increase spacing between dt tags

    how to zoom the background-image in ie8 with css

    How do I customize an asp:Button class?

    How to use jQuery to detect loaded background image after inserting out CSS