JQuery gets the first column of the loop list, and the first column of jquery.

Source: Internet
Author: User

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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.