Created
August 16, 2015 21:47
-
-
Save tmslnz/67e2899416ed8598e7c6 to your computer and use it in GitHub Desktop.
Get whole paragraph from text selection
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
// Discussion here: http://stackoverflow.com/questions/845390/javascript-to-get-paragraph-of-selected-text-in-web-page | |
var selection = window.getSelection(); | |
var textNode = selection.anchorNode.parentNode; | |
var text = textNode.innerHTML; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment