87,922
社区成员
发帖
与我相关
我的任务
分享
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>无标题页</title>
<script type="text/javascript">
function window.onload(){
var doc=document.getElementById("b1");
alert(doc); //[object HTMLIputElement]
alert(doc.nextSibling); //[object Text]
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="b1" value="1"/>
<input type="button" id="b2" value="2"/>
</div>
</form>
</body>
</html>
var next=function(obj) {
if(obj.nextElementSibling)
return obj.nextElementSibling;
return obj.nextSibling;
}
var doc=document.getElementById("b1");
alert(doc); //[object HTMLIputElement]
alert(doc.nextSibling); //[object Text]
var next = doc.nextSibling;
if(next){
while(next.nodeType == 3){//是文本节点
next = doc.nextSibling;
}
}
alert(next.id);