Skip to content

Instantly share code, notes, and snippets.

@malditojavi

malditojavi/html Secret

Created September 14, 2017 18:13
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 malditojavi/c185ff0fc608b23f8d9b28cb4a297ab8 to your computer and use it in GitHub Desktop.
Save malditojavi/c185ff0fc608b23f8d9b28cb4a297ab8 to your computer and use it in GitHub Desktop.
Hack Price Match 5
function isSelectedText(txt) {
return window.getSelection().toString().trim() === txt;
}
function DoThisWhenTextIsSelected() {
// If text selected is equal to our product name
if (isSelectedText(document.getElementById("productname").textContent)) {
// show our cta
document.getElementById("hiddencta").className = "visibleCTA";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment