Skip to content

Instantly share code, notes, and snippets.

@tvaliasek
Created February 13, 2015 14:57
Show Gist options
  • Save tvaliasek/423385165ae298b9d950 to your computer and use it in GitHub Desktop.
Save tvaliasek/423385165ae298b9d950 to your computer and use it in GitHub Desktop.
Simple jQuery email obfuscation function
/*
* Simple jQuery function for email obfuscation
*
*<a href="mailto:some#zavinac#email.cz" target="_blank" title="Email link">some#zavinac#email.cz</a>
*
*/
jQuery(function(){
$("a[href^='mailto:']").each(function(){
var $repl = $(this).attr('href');
$(this).attr('href', $repl.replace(/(\#zavinac\#)/ig, '@'));
$repl = $(this).text();
$(this).text($repl.replace(/(\#zavinac\#)/ig, '@'));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment