Javascript examples for DOM HTML Element:TableData
The TableData object represents an HTML <td> element.
You can access a <td> element by using getElementById():
<!DOCTYPE html> <html> <head> <style> table, th, td { border: 1px solid black; } </style>//from ww w . jav a 2s . c om </head> <body> <table> <tr> <td id="myTd">Cell 1</td> <td>Cell 2</td> </tr> </table> <button onclick="myFunction()">change the text of the first TD element</button> <p id="demo"></p> <script> function myFunction() { var x = document.getElementById("myTd"); x.innerHTML = "NEW"; } </script> </body> </html>