Created
April 5, 2021 08:38
-
-
Save sanjaytj/98fe1388b910acdfefe952a4b849109a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p id="demo"> This element has extra spacing and contains <span>a span element</span>.</p> | |
<button onclick="getInnerText()">Get innerText</button> | |
<button onclick="getHTML()">Get innerHTML</button> | |
<button onclick="getTextContent()">Get textContent</button> | |
<p id="demo"></p> | |
<script> | |
function getInnerText() { | |
alert(document.getElementById("demo").innerText) | |
} | |
function getHTML() { | |
alert(document.getElementById("demo").innerHTML) | |
} | |
function getTextContent() { | |
alert(document.getElementById("demo").textContent) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment