Skip to content

Instantly share code, notes, and snippets.

@dbushell
Created March 16, 2015 09:16
Show Gist options
  • Save dbushell/fec0ba804e4f06c46d4d to your computer and use it in GitHub Desktop.
Save dbushell/fec0ba804e4f06c46d4d to your computer and use it in GitHub Desktop.
Fake links in jQuery, useful for making whole elements clickable while the actual <a> is smaller inside.
$(document).on('click', '[data-href]', function(e)
{
var t = e.target;
if (t && t.nodeType === 1 && t.nodeName.toLowerCase() === 'a') {
return;
}
window.location.href = $(e.currentTarget).data('href');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment