Skip to content

Instantly share code, notes, and snippets.

@bilalucar
Created June 7, 2017 12:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bilalucar/988136383f98e6a9d820959115e1743f to your computer and use it in GitHub Desktop.
Save bilalucar/988136383f98e6a9d820959115e1743f to your computer and use it in GitHub Desktop.
Medium Menu -7
function onMouseUp() {
var sel = document.getSelection(),
txt = sel.toString();
if (txt !== "") {
var range = sel.getRangeAt(0);
if (range.startContainer.parentElement.parentElement.localName
=== "article"
|| range.startContainer.parentElement.localName
=== "article") {
// some text in the article was selected
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment