How to dynamically change the style tag using JavaScript?

前端 未结 9 2079
走了就别回头了
走了就别回头了 2021-01-01 21:50

I want to change the style tag after generating contents. How can I add style to the style tag? I tried using:

document.getElementById(\'style\').appendChil         


        
9条回答
  •  被撕碎了的回忆
    2021-01-01 22:40

    You are probably trying to add css to the style tag. This can be accomplished using:

    document.getElementsByTagName('style')[0].innerHTML=""; //some css goes here
    

    You can also use:

    document.styleSheets[0].cssText = ""; //some css goes here
    

提交回复
热议问题