JS method to get the td value in Table, js method to get tabletd
This article describes how to get the td value in Table by JS. Share it with you for your reference. The details are as follows:
1. To obtain any TD in multiple rows, set a common class for each TD.
Copy codeThe Code is as follows: <tr>
<Td style = "display: none" id = "td2"> 002 </td>
<Td style = "text-align: left; text-decoration: underline;" id = "td2" class = "mouse_hover"> Internet promotion of the love traffic APP </td>
<Td style = "text-align: left;"> group marketing </td>
<Td style = "text-align: left;"> 2015-3-16 </td>
<Td style = "text-align: left;"> 2015-3-25 </td>
<Td style = "text-align: center;"> 11 </td>
<Td> </td>
</Tr>
In the initialization method:
$ (Document ). ready (function () {$ (". mouse_hover "). click (function () {// $ (this ). context. innerHTML // same effect as alert ($ (this ). text (); // alert ("222" + $ (this ). context. innerText );})});
2. Set the value of TD and the id of TD:
document.getElementById('td1').innerHTML
I hope this article will help you design javascript programs.