I have a script I am using that will change a link from a regular link to a mailto link. The idea is most bad robots will not parse javascript thus is a bit better than putting the email address as is or spacing and spelling the @ symbol.
The HTML should render as:
Contact our Sales Manager by email.
The word email would be a link to the email. However with the JS code it renders as so:
Contact our Sales Manager by [email protected].
I would like the first sentence to be how the page renders.
Here is the code:
HTML:
<p>Contact our Sales Manager by
<a class="email" title="email/email.com" href=" ">email</a>.
</p>
JS:
$(function() {
$('a.email').each(function(){
var e = this.title.replace('/','@');
$(this).text().replace('/','@');
this.href=" ";
this.href = 'mailto:' + e; $(this).text(e);
});
});
How would I modify the script to leave the word email in there but create the link correctly?