Created
August 28, 2014 17:56
-
-
Save emaildano/c6b6dceb6efcf6efcb6d to your computer and use it in GitHub Desktop.
Adds mailto: prefix to email links within a filter.
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
// Add mailto: email links within .main | |
$(".main").filter(function() { | |
var html = $(this).html(); | |
var emailPattern = /[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/; | |
var matched_str = $(this).html().match(emailPattern); | |
if (matched_str) { | |
$(this).html(html.replace(emailPattern, "<a href='mailto:" + matched_str + "'>" + matched_str + "</a>")); | |
return $(this); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment