开发者

jQuery 1.4.x and the @ symbol

开发者 https://www.devze.com 2022-12-26 14:18 出处:网络
I used to use this script for jquery email obfuscation: $(\".replaceAt\").replaceWith(\"@\"); $(\".obfuscate\").each(function () {

I used to use this script for jquery email obfuscation:

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

<a class="ob开发者_如何学Gofuscate">name<span class="replaceAt">-AT-</span>server.com</a>

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

uncaught exception: Syntax error, unrecognized expression: @

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?


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.

Edit:

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

精彩评论

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