两个input之间有个空格(回车),
情况就像是两个input之间有个字符串一样
所以第一个input的nextSibling是那个字符串,
如果不去掉这个空格(字符串)
想取到第二个input就得用:<input name="t1" onclick="alert(this.nextSibling.nextSibling.tagName)" value="点我">
 <input name="t2" >

解决方案 »

  1.   

    另外,td与td间的空格符被忽略掉,所以点td时的效果正如你所预期。
      

  2.   

    哦,知道了,但有没有办法处理<input>与<input>之间的空格呢?
      

  3.   

    处理方式如:
     <input name="t1" onclick="alert(this.nextSibling.data='hello')" value="点我">dddd
     <input name="t2" >这个对象是TextNode,看一下参考书就知道了。TextNode Object--------------------------------------------------------------------------------Represents a string of text as a node in the document hierarchy.ResUse the createTextNode method to create a TextNode object. Once you create the TextNode, you can add to it using the appendChild, replaceNode, or insertBefore methods.This object is available in script as of Microsoft&reg; Internet Explorer 5.MembersAllAttributesPropertiesMethodsEventsCollectionsBehaviors   Description 
    data  Sets or retrieves the value of a TextNode object. 
    length  Retrieves the number of characters in a TextNode object. 
    nextSibling  Retrieves a reference to the next child of the parent for the specified object. 
    nodeName  Retrieves the name of a particular type of node. 
    nodeType  Retrieves the type of the requested node. 
    nodeValue  Sets or retrieves the value of a node. 
    previousSibling  Retrieves a reference to the previous child of the parent for the specified object. 
    splitText  Divides a text node at the specified index. 
      

  4.   

    非常感谢,知道处理方法就行textNode对象的属性方法我知道的!向下面这样有没有空间都一样行了!
    <input name="t1" onclick="e=this.nextSibling;if(!e.tagName)e=e.nextSibling;alert(e.value);" value="点我">       <input name="t2" >
    <input name="t1" onclick="e=this.nextSibling;if(!e.tagName)e=e.nextSibling;alert(e.value);" value="点我"><input name="t2" >