jQuery 1.4.x和@符号 [英] jQuery 1.4.x and the @ symbol
问题描述
我曾经使用此脚本进行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?
推荐答案
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屋!