var path = document.getElementsByTagName("path");
(function fillCss(){ for(var i in path){
path[i].setAttribute("fill","none");
path[i].setAttribute("stroke","black");
path[i].setAttribute("stroke-width","0.5");
}
})();样式被执行但是报错:
Uncaught TypeError: path[i].setAttribute is not a function(…)
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
因为path是一个类数组,内部包含一个length属性,这个length属性也是参与for in遍历的,然而他并没有setAttribute,所以此处会报错