nextSibling 获取对此对象的下一个兄弟对象的引用。 nextSibling Property Internet Development Index --------------------------------------------------------------------------------Retrieves a reference to the next child of the parent for the object.What's New for Microsoft® Internet Explorer 6 This property now applies to the attribute object. SyntaxHTML N/A Scripting [ oElement = ] object.nextSibling Possible ValuesoElement Object that receives the next sibling. The property is read-only. The property has no default value.ExampleThis example uses the nextSibling property to obtain the next item in the list.HideExample<SCRIPT> // returns the list item labeled 'List Item 2' var oSibling = oList.childNodes(0).nextSibling; </SCRIPT> <BODY> <UL ID = oList> <LI>List Item 1 <LI>List Item 2 <LI>List Item 3 </UL> <BODY>previousSibling 获取对此对象的上一个兄弟对象的引用。 previousSibling Property Internet Development Index --------------------------------------------------------------------------------Retrieves a reference to the previous child of the parent for the object. What's New for Microsoft® Internet Explorer 6 This property now applies to the attribute object. SyntaxHTML N/A Scripting [ oElement = ] object.previousSibling Possible ValuesoElement Object that receives a reference to the previous sibling of an object. The property is read-only. The property has no default value.ExampleThis example uses the previousSibling property to obtain the previous sibling of a list item.HideExample<SCRIPT> // returns the list item labeled 'List Item 1' var oSibling = oList.childNodes(1).previousSibling; </SCRIPT> : <BODY> <UL ID = oList> <LI>List Item 1 <LI>List Item 2 <LI>List Item 3 </UL> </BODY> Standards InformationThis property is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
这里的This代表控件input,那么后面的span怎么通过this指定?
This property now applies to the attribute object. SyntaxHTML N/A
Scripting [ oElement = ] object.nextSibling Possible ValuesoElement Object that receives the next sibling. The property is read-only. The property has no default value.ExampleThis example uses the nextSibling property to obtain the next item in the list.HideExample<SCRIPT>
// returns the list item labeled 'List Item 2'
var oSibling = oList.childNodes(0).nextSibling;
</SCRIPT>
<BODY>
<UL ID = oList>
<LI>List Item 1
<LI>List Item 2
<LI>List Item 3
</UL>
<BODY>previousSibling 获取对此对象的上一个兄弟对象的引用。
previousSibling Property Internet Development Index --------------------------------------------------------------------------------Retrieves a reference to the previous child of the parent for the object. What's New for Microsoft® Internet Explorer 6
This property now applies to the attribute object. SyntaxHTML N/A
Scripting [ oElement = ] object.previousSibling Possible ValuesoElement Object that receives a reference to the previous sibling of an object. The property is read-only. The property has no default value.ExampleThis example uses the previousSibling property to obtain the previous sibling of a list item.HideExample<SCRIPT>
// returns the list item labeled 'List Item 1'
var oSibling = oList.childNodes(1).previousSibling;
</SCRIPT>
:
<BODY>
<UL ID = oList>
<LI>List Item 1
<LI>List Item 2
<LI>List Item 3
</UL>
</BODY>
Standards InformationThis property is defined in World Wide Web Consortium (W3C) Document Object Model (DOM) Level 1 .
<BODY>
<table id="tab1" border="1">
<tr>
<td><input type="text" name="t1" onClick="alert(t1.nextSibling.value)" value="t1"></td>
<td><input type="text" name="t2" onBlur="" value="t2"></td>
</tr>
</table>
<BODY>要是有表格怎么办?,请高手看看,怎么处理这样得情况,要是在一个页面中有多个t1,
但是我希望在某一节点下面,例如在节点t1处,我想获得t2对象元素,请问怎么实现?
<BODY>
<table id="tab1" border="1">
<tr>
<td>
<input type="text" name="t1" onClick="alert('显示t2得value')" value="t1">
</td>
<td>
<input type="text" name="t2" onBlur="" value="t2">
</td>
</tr>
<table>
<table id="tab1" border="1">
<tr>
<td>
<input type="text" name="t1" onClick="alert('显示t2得value')" value="t11">
</td>
<td>
<input type="text" name="t2" onBlur="" value="t22">
</td>
</tr>
<table>
</BODY>
<tr>
<td>
<input type="text" name="t1" onClick="alert(this.parentElement.parentElement.all.t2.value)" value="t1">
</td>
<td>
<input type="text" name="t2" onBlur="" value="t2">
</td>
</tr>
<tr>
<td>
<input type="text" name="t1" onClick="alert(this.parentElement.parentElement.all.t2.value)" value="t11">
</td>
<td>
<input type="text" name="t2" onBlur="" value="t22">
</td>
</tr>
<table>
大家帮看看,为什么不行?
<BODY>
<input type="text" name="t1">
<input type="text" name="t2">
<BODY>
<SCRIPT>
// returns the list item labeled 'List Item 2'
var oSibling = t1.nextSibling;
alert(oSibling.tagName);
</SCRIPT>
<tr>
<td>
<input type="text" name="t1" value="" onClick="alert(this.parentElement.nextSibling.childNodes[0].tagName);">
</td>
<td>
<input type="text" name="t2" value="t22">
</td>
</tr>
</table>
document.all.t1.parentElement.nextSibling.childNodes[0].value
<table id="tab1">
<tr>
<td>
<input type="text" name="t1" value="" onClick="getValue();">
</td>
<td><span id='t2' value="555">id</span>
<input type="text" name="t2" value="t22">
<input type="text" name="t2" value="t23">
</td>
</tr>
</table>
</FORM></BODY>
</HTML>
<SCRIPT LANGUAGE="JavaScript">
<!--
function getValue()
{
var len = document.all.t1.parentElement.nextSibling.childNodes.length;
for(var i=0;i<len;i++)
{
var nextname =document.all.t1.parentElement.nextSibling.childNodes[i].tagName;
var nextvalue =document.all.t1.parentElement.nextSibling.childNodes[i].value;
alert("name="+nextname+"nextvalue="+nextvalue); }}
//-->
</SCRIPT>