[quote=引用 1 楼 showbo 的回复:] 标准浏览器下空白节点也算,所以this.nextSibling得到的是空白节点,你要获取下一个input,去掉-号和text之间的空白 <td align="center"> <input type="button" value="-" onclick="alert(this.nextSibling.nodeValue)"/><input type="text" size="3" readonly value="6"/><input type="button" value="+"/> </td> Web开发学习资料推荐 Web前端开发框架 javascript运行机制浅析
<td align="center"> <input type="button" value="-" onclick="alert(this.nextSibling.nodeValue)"/><input type="text" size="3" readonly value="6"/><input type="button" value="+"/> </td>
标准浏览器下空白节点也算,所以this.nextSibling得到的是空白节点,你要获取下一个input,去掉-号和text之间的空白 <td align="center"> <input type="button" value="-" onclick="alert(this.nextSibling.nodeValue)"/><input type="text" size="3" readonly value="6"/><input type="button" value="+"/> </td> Web开发学习资料推荐 Web前端开发框架 javascript运行机制浅析
8.7w+
社区成员
22.4w+
社区内容