jquery遍歷table的tr獲取td的值實現方法
來源:易賢網 閱讀:2545 次 日期:2016-06-25 15:36:46
溫馨提示:易賢網小編為您整理了“jquery遍歷table的tr獲取td的值實現方法”,方便廣大網友查閱!

下面小編就為大家?guī)硪黄猨query遍歷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的值實現方法就是小編分享給大家的全部內容了,希望能給大家一個參考

更多信息請查看網絡編程

扫描二维码关注易贤网公众号

2026國考·省考課程試聽報名

  • 報班類型
  • 姓名
  • 手機號
  • 驗證碼

【备考推荐】2025年事业单位联考系统精讲课,免费试看,配套资料包邮到家

關于我們 | 聯系我們 | 人才招聘 | 網站聲明 | 網站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點 | 投訴建議
工業(yè)和信息化部備案號:滇ICP備2023014141號-1 云南省教育廳備案號:云教ICP備0901021 滇公網安備53010202001879號 人力資源服務許可證:(云)人服證字(2023)第0102001523號
聯系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關注公眾號:hfpxwx
咨詢QQ:1093837350(9:00—18:00)版權所有:易賢網