关于JS中查看当前节点的兄弟节点的使用

时间:2022-04-11 00:05:25

<tr>
<td align="center"><input style="width: 20px;" type="checkbox" name="ck" /></td>
<td align="left"><input name="wgrkbillentry[0].fitemid" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fitemname" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fmodel" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fbatchno" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].funitid" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fauxqtymust" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input ondblclick="fun_tevl(this);" name="wgrkbillentry[0].fauxqty" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fpurchaseprice" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fauxprice" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].famount" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fpurchaseamount" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].ftaxrate" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].ftaxamount" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fdcstockid" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fsourcebillno" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left"><input name="wgrkbillentry[0].fnote" maxlength="50" type="text" style="width: 100px;"></td>
<td align="left" style="display: none;"><input name="wgrkbillentry[0].id" type="text" style="width: 0px;"></td>
</tr>

上面是一个tr,没有id,现在对其中的一个name为wgrkbillentry[0].fauxqty的td进行双击事件,下面就是该双击事件

function fun_tevl(ele){
//获取当前节点的父节点tr
  var tr1 = ele.parentNode.parentNode;
//获取父节点的第一个子节点物料
  var b=tr1.cells[1].childNodes[0].value;
}

b就是获取的该兄弟节点的值