Sometimes, we want to insert text in a td with ID using JavaScript.
In this article, we’ll look at how to insert text in a td with ID using JavaScript.
How to insert text in a td with ID using JavaScript?
To insert text in a td with ID using JavaScript, we set the innerHTML
property.
For instance, we write
document.getElementById("td1").innerHTML = "Some text to enter";
to select the td element with getElementById
.
Then we set its innerHTML
property to the text we want to show in the td element.
Conclusion
To insert text in a td with ID using JavaScript, we set the innerHTML
property.