HTML code:
1 <tbodyID= "History_income_list">2 <TR>3 <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD>4 <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD>5 <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD>6 <TDAlign= "Center"><aclass=""onclick= "History_income_del (this);"href="###">Delete</a></TD>7 </TR>8 <TR>9 <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD>Ten <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD> One <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD> A <TDAlign= "Center"><aclass=""href="###">Delete</a></TD> - </TR> - <TR> the <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD> - <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD> - <TDAlign= "Center"><inputtype= "text"class= "Input-s input-w input-hs"></TD> - <TDAlign= "Center"><aclass=""href="###">Delete</a></TD> + </TR> - </tbody> +
Method One:
varTrlist = $ ("#history_income_list"). Children ("tr")) for(vari=0;i<trlist.length;i++) { varTdarr = Trlist.eq (i). Find ("TD"); varHistory_income_type = Tdarr.eq (0). Find (' input '). Val ();//Income category varHistory_income_money = Tdarr.eq (1). Find (' input '). Val ();//Income Amount varHistory_income_remark = Tdarr.eq (2). Find (' input '). Val ();//Notesalert (History_income_type); alert (History_income_money); alert (History_income_remark); }
Method Two:
$ ("#history_income_list"). Find ("tr"). each (function(){ varTdarr = $ ( This). Children (); varHistory_income_type = Tdarr.eq (0). Find (' input '). Val ();//Income category varHistory_income_money = Tdarr.eq (1). Find (' input '). Val ();//Income Amount varHistory_income_remark = Tdarr.eq (2). Find (' input '). Val ();//Notesalert (History_income_type); alert (History_income_money); alert (History_income_remark); });
jquery traverses table tr to get the value of TD