jquery遍历table的tr获取td的值实现方法
2019/6/27 22:25:04
本文主要是介绍jquery遍历table的tr获取td的值实现方法,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
html代码:
<tbody id="history_income_list"> <tr> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><a class="" onclick="history_income_del(this);" href="###">删除</a></td> </tr> <tr> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><a class="" href="###">删除</a></td> </tr> <tr> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><input type="text" class="input-s input-w input-hs"></td> <td align="center"><a class="" href="###">删除</a></td> </tr> </tbody>
方法一:
var trList = $("#history_income_list").children("tr") for (var i=0;i<trList.length;i++) { var tdArr = trList.eq(i).find("td"); var history_income_type = tdArr.eq(0).find("input").val();//收入类别 var history_income_money = tdArr.eq(1).find("input").val();//收入金额 var history_income_remark = tdArr.eq(2).find("input").val();// 备注 alert(history_income_type); alert(history_income_money); alert(history_income_remark); }
方法二:
$("#history_income_list").find("tr").each(function(){ var tdArr = $(this).children(); var history_income_type = tdArr.eq(0).find("input").val();//收入类别 var history_income_money = tdArr.eq(1).find("input").val();//收入金额 var history_income_remark = tdArr.eq(2).find("input").val();// 备注 alert(history_income_type); alert(history_income_money); alert(history_income_remark); });
以上这篇jquery遍历table的tr获取td的值实现方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持找一找教程网。
这篇关于jquery遍历table的tr获取td的值实现方法的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-05-09vue3开发前端表单缓存自定义指令,移动端h5必备插件
- 2024-05-09React Hooks在class组件中的使用方式
- 2024-03-30[OIDC in Action] 2. 基于OIDC(OpenID Connect)的SSO(纯JS客户端)
- 2024-03-29terraform jsonencode
- 2024-03-13vuex-persist
- 2024-03-11icons for vue
- 2024-03-07breadcrumbs react js
- 2024-03-06react login page example
- 2024-03-06react router uselocation
- 2024-03-04postgres jsonb_set