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

<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,很容易出错.

 

posted @ 2015-12-18 14:34  slimo  阅读(874)  评论(0编辑  收藏  举报