HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>This example will demonstrate the difference between "innerHTML" vs "innerText" vs "textContent".</p> <p>Text with <b>spacing</b>.</p> <button onclick="myinnerHTML()">innerHTML</button> <button onclick="myinnerText()">innerText</button> <button onclick="mytextContent()">textContent</button> <script> var y = document.getElementsByTagName("p")[1]; function myinnerHTML(){ alert(y.innerHTML); } function myinnerText(){ alert(y.innerText); } function mytextContent(){ alert(y.textContent); } </script> </body> </html>
OUTPUT
×

Save as Private