Categories
JavaScript Answers

How to change the buttons text using JavaScript?

Spread the love

Sometimes, we want to change the buttons text using JavaScript.

In this article, we’ll look at how to change the buttons text using JavaScript.

How to change the buttons text using JavaScript?

To change the buttons text using JavaScript, we set the innerText property.

For instance, we write

document.getElementById('ShowButton').innerText = 'Show filter';

to select the button with getElementById.

Then we set the innerText property of the button to the text we want to show the button with the text we set.

Conclusion

To change the buttons text using JavaScript, we set the innerText 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 *