jQuery 1.4.x和@符号 [英] jQuery 1.4.x and the @ symbol

查看:82
本文介绍了jQuery 1.4.x和@符号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我曾经使用此脚本进行jquery电子邮件混淆:

I used to use this script for jquery email obfuscation:

    $(".replaceAt").replaceWith("@");
  $(".obfuscate").each(function () {
        $(this).attr("href", "mailto:"+$(this).text());
    });

<a class="obfuscate">name<span class="replaceAt">-AT-</span>server.com</a>

但是使用jQuery 1.4.x,我现在收到此错误:

But with jQuery 1.4.x, I now get this error:

未捕获的异常:语法错误,无法识别的表达式:@

uncaught exception: Syntax error, unrecognized expression: @

在网上查找时,看起来jQuery认为@是一个特殊字符.我试着"\ @"它和其他一些运气不好的东西.我还不足以使用jQuery忍者来解决此问题.有什么想法吗?

Looking this up on the net, it looks like jQuery thinks that the @ is a special character. I tried to "\@" it and a few other things with not luck. I'm not enough of a jQuery ninja to know how to fix this. Any ideas?

推荐答案

因此,我在jQuery发行说明中进行了研究,并且可能

So I dug around in the jQuery release notes, and it might be related to this bug which was fixed in the 1.4.2 release. At any rate, I can verify that your script works great in 1.4.2. Hope this helps.

$(document).ready(function() {
  $(".replaceAt").replaceWith("@");
  $(".obfuscate").each(function () {
    $(this).attr("href", "mailto:"+$(this).text());
   });
});

这篇关于jQuery 1.4.x和@符号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆