Implementation Method for jquery to retrieve td value by traversing table tr, jquerytr
Html code:
<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"> <class = "" onclick = "history_income_del (this ); "href =" ### "> Delete </a> </td> </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 = "###"> Delete </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 = "## # "> Delete </a> </td> </tr> </tbody>
Method 1:
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 (); // revenue type var history_income_money = tdArr. eq (1 ). find ("input "). val (); // revenue amount var history_income_remark = tdArr. eq (2 ). find ("input "). val (); // note alert (history_income_type); alert (history_income_money); alert (history_income_remark );}
Method 2:
$ ("# History_income_list "). find ("tr "). each (function () {var tdArr = $ (this ). children (); var history_income_type = tdArr. eq (0 ). find ("input "). val (); // revenue type var history_income_money = tdArr. eq (1 ). find ("input "). val (); // revenue amount var history_income_remark = tdArr. eq (2 ). find ("input "). val (); // note alert (history_income_type); alert (history_income_money); alert (history_income_remark );});
The implementation of the above jquery traversal table tr to get the td value is all the content shared to you by xiaobian, I hope to give you a reference, but also hope you can support a lot of help homes.