Created
April 3, 2016 13:39
-
-
Save gdarko/8ed80888a1bf917a6ed27dcb5a0a2b02 to your computer and use it in GitHub Desktop.
jQuery Linkify
This file contains 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
$.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