Skip to content

Instantly share code, notes, and snippets.

@MatthieuScarset
Created December 16, 2015 16:54
Show Gist options
  • Save MatthieuScarset/831d77bedc6338e66d00 to your computer and use it in GitHub Desktop.
Save MatthieuScarset/831d77bedc6338e66d00 to your computer and use it in GitHub Desktop.
make an element clickable
// How to use?
makeClick($('.clickable')); //Make things clickable
/*
* Make an HTML element clickable
* Usefull for a fully clickable div without to wrap it in a <a>
* @param $el jQuery DOM object(s)
* return void
*/
function makeClick($el) {
$el.on("click", function () {
$(this).style.cursor = "pointer";
window.location = $(this).find("a").attr("href");
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment