为了账号安全,请及时绑定邮箱和手机立即绑定

有关参数的问题。

有关参数的问题。

哆啦的时光机 2018-09-12 16:13:50
<!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>
查看完整描述

1 回答

?
MM们

TA贡献1886条经验 获得超2个赞

不传的话,执行的时候

sheet.deleteRule(undefined);

可以执行,但是没法删除


查看完整回答
反对 回复 2018-10-11
  • 1 回答
  • 0 关注
  • 558 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信