How to change div content with JavaScript?

Spread the love

Sometimes, we want to change div content with JavaScript.

In this article, we’ll look at how to change div content with JavaScript.

How to change div content with JavaScript?

To change div content with JavaScript, we set its innerHTML property.

For instance, we write

document.getElementById("content").innerHTML = "whatever";

to select the div with getElementById.

Then we set its innerHTML property to the content we want.

Conclusion

To change div content with JavaScript, we set its innerHTML property.

Leave a Reply

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