Skip to content

Instantly share code, notes, and snippets.

@royvandam
Created November 9, 2013 15:42
Show Gist options
  • Save royvandam/7386686 to your computer and use it in GitHub Desktop.
Save royvandam/7386686 to your computer and use it in GitHub Desktop.
Simple email addresses protection using jQuery
/**
* 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