jquery Lookup TR TD Sample Simulation _jquery

Source: Internet
Author: User
Today, someone in the group suddenly asked me $ ("#MainContent_GridView1"). Closest ("tr"). Children ("Td:eq (1)"). Text () This statement does not find a value. I asked him to take a tr below eq (1) of TD's text or all. He said all the .... Then sure to cycle all of the TR, and then from which to find TD ...

Here I write a simple blog to help friends who still don't know how to use the jquery selector.

I simulate a table out, to give you a reference, the following is the HTML structure
Copy Code code as follows:

<table id= "Maincontent_gridview1" >
<tbody>
<tr >
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr >
<td>11</td>
<td>22</td>
<td>33</td>
</tr>
;tr>
<td>111</td>
<td>222</td>
<td>333</td>
</tr> Br></tbody>
</table>

//I introduced a local jquery file that was not introduced in the article. The

<script type= "Text/javascript" >
$ (function () {

///First finds the table ID as Maincontent_gridview1, and then Find tbody below all the TR then each loop, $ (this) on behalf of the current loop to the Tr,children is the TD under TR then select the subscript is 1 again text () came out.

$ ("#MainContent_GridView1 tbody tr"). each (function (i) {
Alert ($ (this). Children ("Td:eq (1)"). text ());
});
})
</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.