JQuery gets the first column of the loop list, and the first column of jquery.
The following table is available:
<Table class = "list_tab" id = "personalDetail"> <tr class = "head"> <th> health check number </th> <th> name </th> <th>> gender </th> <th> age </th> <th> individual status </th> <th> unit name </th> </tr> <td recordid = "201407220001"> 201407220001 </td> <td> moving toward hope </td> <td> male </td> <td> 100 </td> <td> very good </td> <td> xxx Co., Ltd. </td> </tr> <td recordid = "201407220002"> 201407220002 </td> <td> hope forward </td> <td> male </td> <td> 100 </td> <td> good </td> <td> xxx Co., Ltd. </td> </tr> <td recordid = "201407220003"> 201407220003 </td> <td> moving toward hope </td> <td> male </td> <td> 100 </td> <td> good </td> <td> xxx Co., Ltd. </td> </tr> </table>
:
Now I want to retrieve all values in the first column of the list and separate them with commas.
The jQuery code is as follows:
$("#personalDetail tr[recordId]").each(function(i){allRecordIds+=$(this).attr("recordId")+",";});alert(allRecordIds);
How does jquery cyclically retrieve the value of each text box in the table?
Loop? What format of data should be formed? Please make it clear.
If you want to write a word, you can see:
$ (Function (){
Var objList = []; // For example, it exists in this object array.
$ ('Table # myTable input [name = name] '). each ($ (I, n) {// note that name = name is used instead of id = name, because ID must be unique
Var obj = {};
Obj ['name'] = $ (n). val ();
ObjList [I] = obj;
});
$ ('Table # myTable input [name = sex] '). each ($ (I, n ){
ObjList [I] = obj;
Obj ['sex'] = $ (n). val ();
});
$ ('Table # myTable input [name = address] '). each ($ (I, n ){
ObjList [I] = obj;
Obj ['address'] = $ (n). val ();
});
});
Jquery gets the page for loop Value
<Ul id = "list"> <li> 1 </li> <li> 2 </li> <li> 3 </li> </ul> <script> var list = document. getElementById ("list"); var lis = list. getElementsByTagName ("li"); for (var I = 0; I <lis. length; I ++) {lis [I]. onclick = (function (I) {return function () {alert (I) }}) (I) // closure} </script>