HTML Editor
<!DOCTYPE html> <html lang="en-US"> <body> <p>Difference between innerText vs outerText. Try innerText and then outerText.</p> <button onclick="myInnerText()">innerText</button> <button onclick="myOuterText()">outerText</button> <p>Output: <b></b></p> <p><strong>Note</strong>: 'outerText' is not recommended. Open your console (Press F12). and try this example (Second click on 'outerText' button will throw an error).</p> <script> var x = document.getElementById("point"); var elem = document.getElementsByTagName("b")[0]; function myInnerText(){ elem.innerText = "Hello world"; } function myOuterText(){ elem.outerText = "Hello world"; } </script> </body> </html>
OUTPUT
×

Save as Private