Last active
August 29, 2015 14:14
-
-
Save alanmarcos/8abdeab0ace73b3e3f88 to your computer and use it in GitHub Desktop.
make any element clickable
This file contains hidden or 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
$('[data-clickable]').css('cursor', 'pointer').on('click', function(){ | |
var $this = $(this), | |
elm = $this.data('clickable'), | |
url = elm.trim()? $this.find(elm).attr('href') : $this.find('a').attr('href'); | |
window.location.href = url; | |
return false; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage:
or for when there's multiple links: