Skip to content

Instantly share code, notes, and snippets.

@suplo
Created May 22, 2017 01:44
Show Gist options
  • Save suplo/acfbb39525a3c387b062c8f97a7e5ac6 to your computer and use it in GitHub Desktop.
Save suplo/acfbb39525a3c387b062c8f97a7e5ac6 to your computer and use it in GitHub Desktop.
innerText vs innerHTML, textContent
`<p id="test"> This element contains <span>an inner span</span>. </p>`
The values of these properties of the "test" paragraph will be:
* innerText: "This element contains an inner span." :point_left: Just the text, trimmed and space-collapsed.
* innerHtml: " This element contains <span>an inner span</span>. " :point_left: All spacing and inner element tags.
* textContent: " This element contains an inner span. " :point_left: Spacing, but no tags.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment