Categories
JavaScript Answers

How to insert text in a td with ID using JavaScript?

Spread the love

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.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *