Categories
JavaScript Answers

How to change div content with JavaScript?

Spread the love

To change div content with JavaScript, we set the div’s innerHTML property.

For instance, we write

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

to select the div with getElementById.

And then we set its innerHTML property to the content of it.

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 *