Created
August 25, 2021 03:03
-
-
Save johnmurch/ca343045ae7f3041cb734af12af9d820 to your computer and use it in GitHub Desktop.
Remove HTML from String
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
| function stripHtml(html){ | |
| var temporalDivElement = document.createElement("div"); | |
| temporalDivElement.innerHTML = html; | |
| return temporalDivElement.textContent || temporalDivElement.innerText || ""; | |
| } | |
| // let html = "<div><p>Whatever</p><p>This is a <b>test</b></p></div>"; | |
| // console.log(stripHtml(html)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment