zoukankan      html  css  js  c++  java
  • js在head里插入style样式

    代码如下:

    1 var nod = document.createElement('style'),   
    2     str = 'body{background:#000;color:#fff} a{color:#fff;text-decoration:none;} a:hover{color:red;text-decoration:underline}';  
    3     nod.type='text/css';  
    4     if (nod.styleSheet) { //ie下  
    5         nod.styleSheet.cssText = str;
    6     } else {
    7         nod.innerHTML = str; //或者写成 nod.appendChild(document.createTextNode(str))  
    8     }
    9     document.getElementsByTagName('head')[0].appendChild(nod); 
  • 相关阅读:
    CF1368F
    CF1083F
    AGC030F
    AGC030E Less than 3
    CF1083C
    CF526G
    CF1408
    CF1408H Rainbow Triples
    CF1408I
    AGC019E
  • 原文地址:https://www.cnblogs.com/niubenbit/p/5562967.html
Copyright © 2011-2022 走看看