<!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);//為什么這里傳一個(gè)參數(shù)也能正常執(zhí)行函數(shù)? } 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>
有關(guān)參數(shù)的問題。
哆啦的時(shí)光機(jī)
2018-09-12 16:13:50