js动态添加style样式
2018-07-08 15:40 忆- 阅读(42379) 评论(0) 收藏 举报var style = document.createElement("style");
style.type = "text/css";
try{
style.appendChild(document.createTextNode("body{background-color:red}"));
}catch(ex){
style.styleSheet.cssText = "body{background-color:red}";//针对IE
}
var head = document.getElementsByTagName("head")[0];
head.appendChild(style);
浙公网安备 33010602011771号