JavaScript traverses a column in a row in the table and prints its value. javascripttable
JavaScript traversal table
1. Description
Traverse a column of a row in the table and print its value
2. Source Code
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3. Implementation result
(1) During Initialization
(2) Click "traverse"
(3) Click "traverse" again"
How to get the td value of a column in a table, javascript jQuery, all rows, as long as they can be implemented
<BODY>
<Table>
<Tr> <td> 11 </td> <td> 12 </td> <td> 13 </td> </tr>
<Tr> <td> 21 </td> <td> 22 </td> <td> 23 </td> </tr>
<Tr> <td> 31 </td> <td> 32 </td> <td> 33 </td> </tr>
</Table>
</BODY>
<Script>
// Tr: eq (0) take the first row td: eq (2) take the third column
// $ ("Tr: eq (0) td: eq (2)"). text () Get: 13
// $ ("Tr: eq (1) td: eq (1)"). text () Get: 22
Alert ($ ("tr: eq (0) td: eq (2)"). text ());
</Script>
You can replace rows and columns with variables!
Please adopt it. Thank you!
How does jquery obtain the value of a column in a table?
Make sure that the JQeruy file is referenced. If yes, check whether an error is returned.
Put the following code into the body tag.
-----------------------------------------------------
<Form id = "formLoad" runat = "server">
<Table>
<Tr>
<Td> 11 </td>
<Td> 12 </td>
</Tr>
<Tr>
<Td> 21 </td>
<Td> 22 </td>
</Tr>
<Tr>
<Td> abc </td>
<Td> 32 </td>
</Tr>
<Tr>
<Td> 41 </td>
<Td> 42 </td>
</Tr>
</Table>
</Form>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ ("Tr td: first-child"). each (function (){
If ($ (this). text () = "abc "){
Alert ("yes ");
}
});
});
</Script>