JS控制CSS样式的方法
群里的兄弟问的效果
无标题文档
p.p1{ background-color:#FF0000;font-size:22px;_
font-family:"方正舒体"; font-weight:100; }
function remove(){
var wc = document.styleSheets[0], i;
for (i = 0 ; i
hello,this is a example of stylesheets
hello,this is a example of stylesheets
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
网上搜到的不错的控制css
JS控制样式
/*这个不要去啊。。*/
* {
font-size:12px;
}
(function () {
if (window.CSSStyleSheet) {
var wc = window.CSSStyleSheet.prototype;
wc.addRule = function (a, b) {
var wc = this;
wc.insertRule(a + "{" + b + "}", wc.cssRules.length);
};
wc.removeRule = function (a) {
var wc = this;
wc.deleteRule(a);
};
wc.__defineGetter__("rules", new Function("return this.cssRules"));
}
})();
var addRule = function (a, b) {
var wc = document.styleSheets[0], i;
for (i = 0 ; i
我是字
控制
.font {
font-size:18px;
font-weight:bold;
line-height:20px;
color:#FF0000;
}
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]