TS人妖系列亚洲一区二区I北条麻妃一区二区三区I五月天av网站Iwww日日夜夜I黄色99Iwwwjizz欧美I日韩欧美免费观看I日本欧美国产I9191黄色I911亚洲精品I国模无码avI欧洲无码av

jquery遍歷table的tr獲取td的值

2021-8-5    前端達人

html代碼:

復制代碼
 1 <tbody id="history_income_list">  2 <tr>  3 <td align="center"><input type="text" class="input-s input-w input-hs"></td>  4 <td align="center"><input type="text" class="input-s input-w input-hs"></td>  5 <td align="center"><input type="text" class="input-s input-w input-hs"></td>  6 <td align="center"><a class="" onclick="history_income_del(this);" href="###">刪除</a></td>  7 </tr>  8 <tr>  9 <td align="center"><input type="text" class="input-s input-w input-hs"></td> 10 <td align="center"><input type="text" class="input-s input-w input-hs"></td> 11 <td align="center"><input type="text" class="input-s input-w input-hs"></td> 12 <td align="center"><a class="" href="###">刪除</a></td> 13 </tr> 14 <tr> 15 <td align="center"><input type="text" class="input-s input-w input-hs"></td> 16 <td align="center"><input type="text" class="input-s input-w input-hs"></td> 17 <td align="center"><input type="text" class="input-s input-w input-hs"></td> 18 <td align="center"><a class="" href="###">刪除</a></td> 19 </tr> 20 </tbody> 21 
復制代碼

 


方法一:

復制代碼
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);

    });
復制代碼

藍藍設計建立了UI設計分享群,每天會分享國內外的一些優秀設計,如果有興趣的話,可以進入一起成長學習,請掃碼ben_lanlan,報下信息,會請您入群。歡迎您加入噢~~希望得到建議咨詢、商務合作,也請與我們聯系。

文章來源:博客園

分享此文一切功德,皆悉回向給文章原作者及眾讀者.
免責聲明:藍藍設計尊重原作者,文章的版權歸原作者。如涉及版權問題,請及時與我們取得聯系,我們立即更正或刪除。

藍藍設計www.gyxygd.cn )是一家專注而深入的界面設計公司,為期望卓越的國內外企業提供卓越的UI界面設計、BS界面設計 、 cs界面設計 、 ipad界面設計 、 包裝設計 、 圖標定制 、 用戶體驗 、交互設計、 網站建設 平面設計服務

日歷

鏈接

個人資料

藍藍設計的小編 http://www.gyxygd.cn

存檔