<body>
<div></div>
<div></div>
<div></div>
<div></div>
<script>
var oDivArray = document.getElementsByTagName('div');
function getStyle(dom,attr){
if (window.getComputedStyle)
{return window.getComputedStyle(dom,null)[attr];}
else
{return currentStyle(dom,null);}
}
</script>
</body>
Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window':
parameter 1 is not of type 'Element'.
1 回答

橋本奈奈未
TA贡献436条经验 获得超108个赞
parameter 1 is not of type
'Element'
报错信息不是很明显吗?第一个参数的类型得是Element,getElementsByTagName是一个HTMLCollection
添加回答
举报
0/150
提交
取消