rules与cssRules区别(ie与firefox)

作者:袖梨 2022-06-25

function addcssrule(css,key,value){
//var css = document.stylesheets[document.stylesheets.length-1];
if(navigator.useragent.indexof("firefox")>0 )
{
css.insertrule(key+"{"+value+"}", css.cssrules.length)
}
else
{
css.addrules(key,value);
}
}
function removecssrule(key){
for(var i = 0; i < document.stylesheets.length; i++){
var css = document.stylesheets[i];
navigator.useragent.indexof("firefox")>0 ?
(function(){
for(var j = 0; j < css.cssrules.length; j++){
if(css.cssrules[j].selectortext==key){
css.deleterule(j);
}
}
})() :
(css.removerule(key)) ;
}
}

 

相关文章

精彩推荐