how to set the text of a html element using js code example Example: set text of dom element document.getElementById("myBtn").textContent = 'Hello World';