IE6、IE7中获取Button元素的值的bug说明_javascript技巧
来源:动视网
责编:小采
时间:2020-11-27 21:00:23
IE6、IE7中获取Button元素的值的bug说明_javascript技巧
IE6、IE7中获取Button元素的值的bug说明_javascript技巧:测试代码如下: 代码如下: 测试 var btn = document.getElementsByTagName('button')[0]; alert(btn.value); alert(btn.getAttribute('value')); IE6/7: IE8/9/10/Firefox/Safari/Chrome/Opera:
导读IE6、IE7中获取Button元素的值的bug说明_javascript技巧:测试代码如下: 代码如下: 测试 var btn = document.getElementsByTagName('button')[0]; alert(btn.value); alert(btn.getAttribute('value')); IE6/7: IE8/9/10/Firefox/Safari/Chrome/Opera:

测试代码如下:
代码如下:
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,实现错误。
IE6、IE7中获取Button元素的值的bug说明_javascript技巧
IE6、IE7中获取Button元素的值的bug说明_javascript技巧:测试代码如下: 代码如下: 测试 var btn = document.getElementsByTagName('button')[0]; alert(btn.value); alert(btn.getAttribute('value')); IE6/7: IE8/9/10/Firefox/Safari/Chrome/Opera: