<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
#box{
color: red
}
</style>
<script>
window.onload=function(){
var base=new Base();
base.removeRule(0,0);
//base.removeRule(0);//为什么这里传一个参数也能正常执行函数?
}
function Base(){};
Base.prototype.removeRule=function(num,index){
var sheet=document.styleSheets[num];
if(typeof sheet.deleteRule !='undefined'){//W3C
sheet.deleteRule(index);
}else if(typeof sheet.removeRule!='undefined'){//IE
sheet.removeRule(index);
}
return this;
}
</script>
</head>
<body>
<div id='box'>box</div>
</body>
</html>
不传的话,执行的时候
可以执行,但是没法删除