两个input之间有个空格(回车),
情况就像是两个input之间有个字符串一样
所以第一个input的nextSibling是那个字符串,
如果不去掉这个空格(字符串)
想取到第二个input就得用:<input name="t1" onclick="alert(this.nextSibling.nextSibling.tagName)" value="点我">
<input name="t2" >
情况就像是两个input之间有个字符串一样
所以第一个input的nextSibling是那个字符串,
如果不去掉这个空格(字符串)
想取到第二个input就得用:<input name="t1" onclick="alert(this.nextSibling.nextSibling.tagName)" value="点我">
<input name="t2" >
解决方案 »
- 请教各位高手,网易邮箱的上传附件组件是如何实现的,点击href链接怎么样可以弹出一个选择文件的框框来,谢谢。
- createElement 创建的对象如何快速设置样式?
- 子窗口如何关闭时刷新父窗口而保留父窗口表单的值
- 关于预览,如何将获取的字段值赋给指定同一标签,作为值显示在html中?
- $(window).scrollTop()为0???
- 在线高分求救:在ASP中,如何动态定义javascript变量?(解答出来再开新贴给分)
- ****进来帮忙看这段程序****
- 在扩展名为js的文件中如何调用vbscript脚本语言(帮帮小妹忙吧!谢谢)
- 谁有javascrip做的计算器,功能强大一点的。拜托!高分!
- js 作用域链的问题
- 请帮我写这样一个简单的js正则表达式,谢谢!
- 郁闷死了,帮帮我,关于字符串的问题
<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® 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.
<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" >