Skip to content

Instantly share code, notes, and snippets.

@lmartins
Created January 24, 2018 16:43
Show Gist options
  • Save lmartins/f636f14f675b77d33bab37caff0a6286 to your computer and use it in GitHub Desktop.
Save lmartins/f636f14f675b77d33bab37caff0a6286 to your computer and use it in GitHub Desktop.
Make entire block clickable
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