Created
January 24, 2018 16:43
-
-
Save lmartins/f636f14f675b77d33bab37caff0a6286 to your computer and use it in GitHub Desktop.
Make entire block clickable
This file contains 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
delegate(document.body, '.js-clickBlock', 'click', function(e) { | |
// If already a link bailout | |
if (e.target.tagName == "A" || e.target.tagName == "BUTTON") { | |
return; | |
} | |
let link = e.delegateTarget.querySelector('a'); | |
if (link && link.href) { | |
e.preventDefault(); | |
window.location.href = link.href; | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment