html代码:
<span style="color: #008080;"> 1 <span style="color: #0000ff;">tbody <span style="color: #ff0000;">id<span style="color: #0000ff;">="history_income_list"<span style="color: #0000ff;">> <span style="color: #008080;"> 2 <span style="color: #0000ff;">tr<span style="color: #0000ff;">> <span style="color: #008080;"> 3 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;"> 4 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;"> 5 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;"> 6 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>a <span style="color: #ff0000;">class<span style="color: #0000ff;">=""<span style="color: #ff0000;"> onclick<span style="color: #0000ff;">="history_income_del(this);"<span style="color: #ff0000;"> href<span style="color: #0000ff;">="###"<span style="color: #0000ff;">>删除<span style="color: #0000ff;"><span style="color: #800000;">a<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;"> 7 <span style="color: #0000ff;"><span style="color: #800000;">tr<span style="color: #0000ff;">> <span style="color: #008080;"> 8 <span style="color: #0000ff;">tr<span style="color: #0000ff;">> <span style="color: #008080;"> 9 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">10 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">11 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">12 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>a <span style="color: #ff0000;">class<span style="color: #0000ff;">=""<span style="color: #ff0000;"> href<span style="color: #0000ff;">="###"<span style="color: #0000ff;">>删除<span style="color: #0000ff;"><span style="color: #800000;">a<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">13 <span style="color: #0000ff;"><span style="color: #800000;">tr<span style="color: #0000ff;">> <span style="color: #008080;">14 <span style="color: #0000ff;">tr<span style="color: #0000ff;">> <span style="color: #008080;">15 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">16 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">17 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>input <span style="color: #ff0000;">type<span style="color: #0000ff;">="text"<span style="color: #ff0000;"> class<span style="color: #0000ff;">="input-s input-w input-hs"<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">18 <span style="color: #0000ff;">td <span style="color: #ff0000;">align<span style="color: #0000ff;">="center"<span style="color: #0000ff;">>a <span style="color: #ff0000;">class<span style="color: #0000ff;">=""<span style="color: #ff0000;"> href<span style="color: #0000ff;">="###"<span style="color: #0000ff;">>删除<span style="color: #0000ff;"><span style="color: #800000;">a<span style="color: #0000ff;">><span style="color: #800000;">td<span style="color: #0000ff;">> <span style="color: #008080;">19 <span style="color: #0000ff;"><span style="color: #800000;">tr<span style="color: #0000ff;">> <span style="color: #008080;">20 <span style="color: #0000ff;"><span style="color: #800000;">tbody<span style="color: #0000ff;">> <span style="color: #008080;">21 </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
方法一:
<span style="color: #0000ff;">var trList = $("#history_income_list").children("tr"<span style="color: #000000;">) <span style="color: #0000ff;">for (<span style="color: #0000ff;">var i=0;i<trlist.length style="color: #000000;">) { <span style="color: #0000ff;">var tdArr = trList.eq(i).find("td"<span style="color: #000000;">); <span style="color: #0000ff;">var history_income_type = tdArr.eq(0).find("input").val();<span style="color: #008000;">//<span style="color: #008000;">收入类别 <span style="color: #0000ff;">var history_income_money = tdArr.eq(1).find("input").val();<span style="color: #008000;">//<span style="color: #008000;">收入金额 <span style="color: #0000ff;">var history_income_remark = tdArr.eq(2).find("input").val();<span style="color: #008000;">//<span style="color: #008000;"> 备注 <span style="color: #000000;"> alert(history_income_type); alert(history_income_money); alert(history_income_remark); }</span></span></span></span></span></span></span></span></span></span></span></span></trlist.length></span></span></span></span>
方法二:
$("#history_income_list").find("tr").each(<span style="color: #0000ff;">function<span style="color: #000000;">(){ <span style="color: #0000ff;">var tdArr = $(<span style="color: #0000ff;">this<span style="color: #000000;">).children(); <span style="color: #0000ff;">var history_income_type = tdArr.eq(0).find("input").val();<span style="color: #008000;">//<span style="color: #008000;">收入类别 <span style="color: #0000ff;">var history_income_money = tdArr.eq(1).find("input").val();<span style="color: #008000;">//<span style="color: #008000;">收入金额 <span style="color: #0000ff;">var history_income_remark = tdArr.eq(2).find("input").val();<span style="color: #008000;">//<span style="color: #008000;"> 备注 <span style="color: #000000;"> alert(history_income_type); alert(history_income_money); alert(history_income_remark); });</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>