Skip to content

Instantly share code, notes, and snippets.

@gdarko
Created April 3, 2016 13:39
Show Gist options
  • Save gdarko/8ed80888a1bf917a6ed27dcb5a0a2b02 to your computer and use it in GitHub Desktop.
Save gdarko/8ed80888a1bf917a6ed27dcb5a0a2b02 to your computer and use it in GitHub Desktop.
jQuery Linkify
$.fn.linkify = function() {
$(this).on("click", function(){
if($(this).attr('data-href')){
window.location.href = $(this).attr('data-href');
}else{
console.log('undefined');
}
})
return this;
};
// The element that has the data-href attribute and will pretend as link.
// You can additionaly change the course to pointer on hover on .js-link class
$('.js-link').linkify();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment