为什么在IE6/7中NodeList未定义?
<form action="/" method="post" id="testform">
<input type="checkbox" name="foobar[]" value="1" id="" />
<input type="checkbox" name="foobar[]" value="2" id="" />
<input type="checkbox" name="foobar[]" value="3" id="" />
</form>
<script type="text/javascript" charset="utf-8">
(function () {
var el = document.getElementById('testform')['foobar[]']
if (el instanceof NodeList) {
alert("I'm a NodeList");
}
})();
</script>
Run Code Online (Sandbox Code Playgroud)
这适用于FF3/Safari 3.1,但在IE6/7中不起作用.任何人都有任何想法如何检查el是否是所有浏览器的NodeList实例?
javascript ×1