欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

jquery遍歷table的tr獲取td的值實(shí)現(xiàn)方法

 更新時(shí)間:2016年05月19日 16:12:56   投稿:jingxian  
下面小編就為大家?guī)硪黄猨query遍歷table的tr獲取td的值實(shí)現(xiàn)方法。小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

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的值實(shí)現(xiàn)方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論