rules与cssRules区别(ie与firefox)

2016-03-02    编辑:kp12345     点击(
rules与cssRules区别(ie与firefox)

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)) ;
}
}