JAVASCRIPT动态创建样式表
index.html:
var link=document.createElement("link");
link.href="style.css";
link.rel="stylesheet";
link.type="text/css";
document.head.appendChild(link);
style.css:
body{
background-color: black;
}
运行结果:

JAVASCRIPT动态创建样式表
index.html:
var link=document.createElement("link");
link.href="style.css";
link.rel="stylesheet";
link.type="text/css";
document.head.appendChild(link);
style.css:
body{
background-color: black;
}
运行结果:
