Simple jQuery plugin to hide email addresses from spambots. If the element is <a>
, it will add the attribute href with respective mailto
.
$('.email').mailto();
To avoid having to set data-host
in multiple email addresses, you can set the default host
in the plugin configuration:
$('.email').mailto({
host:'domain.com'
});
<a class="email" data-account="my.name"></a>
<a class="email" data-account="my.name" data-host="domain.com" data-text="My Email"></a>
<a class="email" data-account="my.name" data-host="domain.com"></a>
<a class="email" data-account="my.name" data-host="domain.com" data-subject="Information Request"></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>
Append email to <a>
<a class="email" data-account="my.name" data-host="domain.com" data-subject="Information Request"><i class="glyphicon glyphicon-envelope"></i></a>
If you set the option prepend
to true
, email is inserted left from the existing child elements.
$('.email').mailto({
prepend:true
});
<a class="email" data-account="my.name" data-host="domain.com" data-subject="Information Request"><i class="glyphicon glyphicon-envelope"></i></a>
<a class="email">my dot name at domain dot com</a>
<span class="email">my dot name at domain dot com</span>