<!DOCTYPE html><html><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>
添加回答
举报
0/150
提交
取消