0

Im trying to load css file in my Jquery function but not able to render the same in UI when i check in View source of page.

   $(document).ready(function () {
        debugger;
        if (Ie.IsBrowserSupported) {
            $("link[href*='site.css']").remove();
            $("head").append($("<link rel='stylesheet' href='ChromeSite.css' 
                type='text/css' media='screen' />"));
        }
    });

ChromeSite.css is not being rendered in stylesheet of the page. Is there Any other way to load the same in Jquery function?

10
  • 1
    Possible duplicate of adding css file with jquery Commented Aug 7, 2019 at 7:09
  • Did you inspect the result in the dev tools? Did you manually break that long line to post it here or is it like that in your actual code? Are you getting any error messages in the console? When I fix the linebreak issue, the append() part works as expected. Keep in mind that "View source" shows the original document received from the server, not the changed DOM! Commented Aug 7, 2019 at 7:10
  • @cloned that didnt work...that's why posted it. Commented Aug 7, 2019 at 7:13
  • @ChrisG append is working as expected but my stylesheet are not getting applied to that page Commented Aug 7, 2019 at 7:14
  • See the network in dev tools for any errors. Commented Aug 7, 2019 at 7:15

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.