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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T12:05:55+00:00 2026-06-03T12:05:55+00:00

The replacement is done in real time – user clicks something, the style changes:

  • 0

The replacement is done in real time – user clicks something, the style changes:

$('link#mystyle').attr('disabled', 'disabled');
$('link#mystyle').remove();

if(new_style){
  $('head').append('<link rel="stylesheet" id="mystyle" href="' 
                    + new_style +'.css" type="text/css" />');

}

The problem is that by default there is a inline style block after the stylesheet link:

<style>
  ...
</style>

And my code above will remove the original stylesheet, and append the new stylesheet after the style block, so the new stylesheet will override some rules from the style block.

I don’t want that, so can I somehow append my new style in the same place, so the rules inside the new stylesheet are applied with the same priority as the initial stylesheet rules?

  • 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-03T12:06:01+00:00Added an answer on June 3, 2026 at 12:06 pm

    @Kroehre is right, but if you insist on doing it your way there is the http://api.jquery.com/replaceWith/ method.

    $('link#mystyle').replaceWith('<link rel="stylesheet" id="mystyle" href="' 
                    + new_style +'.css" type="text/css" />');
    

    should do what you want.

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

Sidebar

Related Questions

I'm testing MySQL as a replacement for SQL server and I'm running into something
I have an automatic replacement done by my vim setup, which systematically replaces all
I have around 3000 instance of replacement done in hundreds of files. Replacing all
I will probably have done it manually by the time I get an answer
I have done text replacement in Javascript such that the <br /> tag will
I am writing a replacement Windows shell in C#, and the feature I am
Is there any replacement for saxon:if and saxon:before functions in XSLT 2.0 / XPath
In a replacement pattern, is there any way to print the NUMBER of the
What is the C# replacement for the following define? #define IS_FINITE(x) (0x7FF0 != (*((unsigned
I am writing a custom replacement for the Textbox/Label controls. It needs to provide

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.