views:

61

answers:

1

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?

+3  A: 
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

Oskar Krawczyk
Thank you very much, Oskar! Works great for me.You are cool and precise as usual.
Nikita Sumeiko
Mentioned your Mootools conversion on one of my blog posts. Great job!
Nikita Sumeiko