textcontent vs innertext vs innerhtml code example

Example 1: change innertext javascript

element.innerText = "Hello World";

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

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

Example 3: 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>!

Example 4: javascript textcontent vs innertext

getValue.innerHTMLThis element is <strong>strong</strong> and has    some super fun <code>code</code>!getValue.innerTextThis element is strong and has some super fun code!getValue.textContentThis element is strong and     has some super fun code!

Example 5: javascript innertext vs innerhtml

innerHTML shows everything inside of the element.
innerText shows only the text inside of the element.

Example 6: innertext vs innerhtml

Inner text below. It inject string as it is into the element.
My name is <b class="name">Raj Yadav</b>.

Inner html below. It renders the string into the element and treat as part of html document.
My name is Raj Yadav.