IE6/7中获取Button元素的值的bug
如下
<button value="abc">测试</button> <script> var btn = document.getElementsByTagName('button')[0]; alert(btn.value); alert(btn.getAttribute('value')); </script>
IE6/7:
IE8/9/10/Firefox/Safari/Chrome/Opera:
IE6/7 中返回的是innerHTML,实现错误。用getAttributeNode修复,如下
<button value="abc">测试</button> <script> var btn = document.getElementsByTagName('button')[0]; alert(btn.getAttributeNode('value').nodeValue); </script>