innerhtml innertext textcontent code example

Example 1: change innertext javascript

element.innerText = "Hello World";

Example 2: HTML DOM innerText

var x = document.getElementById("myBtn").innerText;

Example 3: javascript the difference between innerText vs. innerHTML vs. textContent

getValue.textContent// =>   This element is strong and     has some super fun code!

Example 4: javascript the difference between innerText vs. innerHTML vs. textContent

getValue.innerHTML// =>   This element is <strong>strong</strong> and     has some super fun <code>code</code>!