问题描述
- 新手求助关于根据选中的radio而获取同一行里面的所有td的值
-
求教,想根据选中的radio来获取该radio所在那一行里面的所有的td值(每个td里面的值要分别获取出来)
该怎么做呢?<c:forEach items="${logoutAccountForm.accountList}" var="logoutList"> <tr height="55" class="table_centent_bj_color_b" > <td width="100" class=""><span class="radio_wrap"> <input type="radio" id="xh" name="xh" value="" /> <label for="xh" class="check"></label> </span></td> <td width="350" class="" id="accNo"><p>${logoutList.accNo} </p></td> <td width="200" class="" id="custName"><p>${logoutList.customer.custName} </p></td> <td width="300" class="" id="openBank"><p>${logoutList.openbank} </p></td> <td width="250" class="" id="openDate"><p>${logoutList.openDate} </p></td> </tr> </c:forEach>
解决方案
通多dom关系来获取
$('input[name="xh"]:checked').each(function () {
var tr = $(this).closest('tr'), tds = tr.find('td');
alert(tds.eq(1).text())
alert(tds.eq(2).text())
alert(tds.eq(4).text())
//.....
});
解决方案二:
$(obj).parent("tr").find("td"); 这就是 选中的 radio 对象 获取 父 tr 之后找 tr内部的所有td了
解决方案三:
js 获取radio的选中值 和checkbox 的选中值
解决方案四:
给你的p标签加个id,用js或者jquery一个个取不就行了么
时间: 2024-08-30 11:16:02