开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜