Categories
JavaScript Answers

How to replace text inside a div element with JavaScript?

Spread the love

To replace text inside a div element with JavaScript, we set the innerHTML property.

For instance, we write

fieldNameElement.innerHTML = "My new text!";

to set the innerHTML property of the fieldNameElement element to the new text content.

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 *