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.