$('.email').each(function(l,i){
var that = $(this);
var thatOtherOne = $(this:after);
$('<a>').attr('href', 'mailto: '+ that.html + thatOtherOne.css('content')).insertAfter(that);
that.hide();
});
.email:after {
content: "@mydomain.com";
}
<span class="email">info</span>
Hello again Stackoverflow!
This is my method against spam. Using CSS the :after
selector and content
I try fill my custom email in inside the <span>
and the css adds the url. This doesn't make it clickable though, so that's why I try the above method using JS/jQuery.
This sadly doesn't work because $(this:after);
is not a valid selector. How can I change this?