<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>
//用nextSibling属性无法获得<input type="button" id="b2" value="2"/>
属性,如果想用兄弟节点获得<input type="button" id="b2" value="2"/>元素,该怎么做
解决方案 »
- css里用到js函数的返回结果。该如何调用?
- 请教如何让输入框的输入焦点失效?
- 页面漂浮的兼容问题,IE9,FF不动,其它正常.....
- 用三个文本框。在前两个文本框输入数字,在第三个文本框中显示前两个文本框中的数字的和。
- 关于一个JS读取XML的问题
- 求js日期控件(须要选一个日期时间段)
- 哪位帮我解释下关于document.selection.createRange()的作用和用法?
- 在javascript中有没有办法判断输入框中输入的是否是数值型(包含有小数点的情况),解决了马上给分,thanks!!!!!
- 谁知道如何获取表格TD的背景颜色?(这个背景色是用CSS设置的)
- ComboBox后台json数据处理问题
- js问题
- 一个js函数问题
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);
IE中会忽略掉这些的,doc.nextSibling代表的就是button2
if(obj.nextElementSibling)
return obj.nextElementSibling;
return obj.nextSibling;
}