Get TableData Element - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:TableData


The TableData object represents an HTML <td> element.

You can access a <td> element by using getElementById():

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
table, th, td {
    border: 1px solid black;
</style>//from ww w . jav a 2s  . c om

   <td id="myTd">Cell 1</td>
   <td>Cell 2</td>

<button onclick="myFunction()">change the text of the first TD element</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myTd");
    x.innerHTML = "NEW";


Related Tutorials