Created
September 2, 2013 09:10
-
-
Save juanfernandes/6410854 to your computer and use it in GitHub Desktop.
Get text content from HTML with out html code.
This file contains 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
Let's say you have the following HTML: | |
<div id="module"> | |
<p> | |
This is some <b>example</b> text | |
<span>with some random markup.</span> | |
</p> | |
</div> | |
If you want to grab all the text content inside of #module, you can do this: | |
var module = document.getElementById("module"); | |
var moduleText = module.textContent; | |
console.log(moduleText); | |
// result: | |
// "This is some example text with some random markup." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment