jsp页面出现两个相同id的标签的读取顺序

时间:2015-12-18 16:03:44   收藏:0   阅读:1094

<html>
<script>
function alerts()
{
alert(document.getElementById(‘wb‘).value);
}
</script>

<body>
<input type="text" id="wb"><Br>
<input type="text" id ="wb"><br><Br>
<input type="button" onclick="alerts()" value="查看">
</body>
</html>

 

执行上述的代码发现,浏览器值读了第一个值,而不会读取第二个值.

 

所以不要在同一个页面用不唯一的id,很容易出错.

 

原文:http://www.cnblogs.com/slimo/p/5057013.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!