<a href="javascript:void(0);" id="test1">测试1</a>
<a href="javascript:void(0);" name="test1">测试2</a>
<script type="text/javascript">
var objs = document.getElementsByName('test1');
alert(objs.length);
</script>IE8中的值为2IE11中的值为1
Firefox,Chrome的值为1
本文探讨了在IE8、IE11、Firefox和Chrome浏览器中使用JavaScript获取DOM元素数量的不同结果,并分析了可能的原因。
661

被折叠的 条评论
为什么被折叠?



