IE 的 document.getElementsByName 有 BUG
posted on 2010-03-05 18:51:35+08:00 by david
http://wangblog.org/2010/03/ie-documentgetelementsbyname-bug.html
<div id="test"></div> <script type="text/JavaScript"> var _input; var _test = document.getElementById('test'); _input = document.createElement('input'); _input.type = 'text'; _input.name = 'test[1]'; _input.value = 'test1'; _test.appendChild(_input); _input = document.createElement('input'); _input.type = 'text'; _input.name = 'test[2]'; _input.id = 'test[2]'; _input.value = 'test2'; _test.appendChild(_input); try{ alert(document.getElementsByName('test[1]')[0].value); }catch(e){ alert(e.toString()); } alert(document.getElementsByName('test[2]')[0].value); </script>

