How to load in an external CSS file dynamically?

后端 未结 8 1656
滥情空心
滥情空心 2020-12-14 22:32

I\'m trying to create a dynamic page using external .css pages where the page color will get changed. Below is my code. But when I click the href, I am not gett

8条回答
  •  春和景丽
    2020-12-14 22:56

    First of all, you can't have an anchor element in the section. Secondly, are you sure your CSS path is correct? I'm asking because you already have a reference to css/newstyle.css but your are trying to load newstyle.css. Are you sure it's not css/newstyle.css?

    Edit: Here is a working example of your own code. There is something else wrong. Try to statically link the CSS and see if you are getting the styles. If not, there may be errors in your stylesheet.

    By statically linking the stylesheet, I meant to say add this in your page instead of loading from javascript

    
    

提交回复
热议问题