Created
November 9, 2013 15:42
-
-
Save royvandam/7386686 to your computer and use it in GitHub Desktop.
Simple email addresses protection using jQuery
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
/** | |
* Easy to use, email protection using jQuery. | |
* Just the following to your HTML: | |
* <a href="#"><span class="email" user="me" domain="example" tld=".com"></span></a> | |
*/ | |
$(document).ready(function() { | |
$('.email').html(function() { | |
var address = $(this).attr('user') + '@' + $(this).attr('domain') + $(this).attr('tld'); | |
$(this).parent('a').attr('href', 'mailto:' + address); | |
return address; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment