Skip to content

Instantly share code, notes, and snippets.

@guysolamour
Created November 15, 2017 17:16
Show Gist options
  • Save guysolamour/17a9f14dcb3a810de8a1c5c6147e753a to your computer and use it in GitHub Desktop.
Save guysolamour/17a9f14dcb3a810de8a1c5c6147e753a to your computer and use it in GitHub Desktop.
JS: Jquery mailto plugin
(function($) {
$.fn.mailto = function() {
return this.each(function() {
var $el = $(this),
emailAdd = $el.attr("href").replace(/\s*\(.+\)\s*/, "@"),
emailClass = $el.attr('class'),
emailText = $el.html();
$(this).before('<a href="mailto:' + emailAdd + '" rel="nofollow" class="' + emailClass + '" title="Email ' + email_add + '">' + emailText + '</a>').remove();
});
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment