How to rewrite this jQuery code by using Mootools?
I have a jQuery code, but need it working by using Mootools:
if ( $("span.mailme").length ) {
var at = / AT /;
var dot = / DOT /g;
$('span.mailme').each(function () {
var addr = $(this).text().replace(at, '@').replace(dot, '.'开发者_如何转开发);
$(this).after('<a href="mailto:' + addr + '">' + addr + '</a>');
$(this).remove();
});
}
Is there anyone, who know as good Mootools as jQuery?
var mailme = $$('.mailme'), at = / AT /, dot = / DOT /g;
mailme.each(function(el){
var addr = el.get('text').replace(at, '@').replace(dot, '.');
new Element('a', {
href: 'mailto:'+ addr,
html: addr
}).inject(el, 'after');
el.destroy();
});
Here's a working example: http://jsfiddle.net/oskar/MJujB
精彩评论