Simple jQuery plugin to hide email addresses from spambots. If the element is <a>
, it will add the attribute href with respective mailto
.
Check out the demo page.
$('.email').mailto();
The plugin to avoid having to set data-host
in multiple email addresses, you can set the default host in the plugin:
$('.email').mailto({
host:'domain.com'
});
<a class="email" data-account="my.name"></a>
... will result in...
<a class="email" href="mailto:[email protected]">[email protected]</a>
If you prefer literal email addresses...
<a class="email">my dot name at domain dot com</a>
... will result in...
<a class="email" href="mailto:[email protected]">[email protected]</a>
<a class="email" data-account="my.name" data-host="domain.com" data-text="My Email"></a>
... will result in...
<a class="email" href="mailto:[email protected]">My Email</a>
<a class="email" data-account="my.name" data-host="domain.com"></a>
... will result in...
<a class="email" href="mailto:[email protected]">[email protected]</a>
<a class="email" data-account="my.name" data-host="domain.com" data-subject="Information Request"></a>
... will result in...
<a class="email" href="mailto:[email protected]?subject=Information%20Request">[email protected]</a>
If the element is not a <a>
, it will not set the href attribute:
<span class="email" data-account="my.name" data-host="domain.com"></span>
... will result in...
<span class="email">[email protected]</a>