如何使用 jAlert 转义 jQuery 函数中的实体?
下面是示例代码:
$("#register-button").click(function(){
if (uname=="" || pname=="" || cemail=="" || remail=="") {
jAlert('Please fix the validation error','Title™');
return false;
}
});
基本上,如果用户名、密码或电子邮件字段填写不正确,则会弹出一个 jAlert,显示“请修复验证错误”,其中包含商标标题。不幸的是,该商标并不是一个适当的实体,并且无法正确呈现。
我尝试了以下操作,但它无法正常工作:
$("#register-button").click(function(){
if (uname=="" || pname=="" || cemail=="" || remail=="") {
jAlert('Please fix the validation error','Title™');
return false;
}
});
如您所见,唯一的区别是我包含了 ™
。然而,当 jAlert 弹出时,它不会变成™。
如何转义 jQuery 以便该实体正确呈现?
Here's sample code:
$("#register-button").click(function(){
if (uname=="" || pname=="" || cemail=="" || remail=="") {
jAlert('Please fix the validation error','Title™');
return false;
}
});
Basically, if username, password, or email fields aren't filled correctly, a jAlert pops up that says "Please fix the validation error" containing a title that's trademarked. Unfortunately, this trademark is not properly an entity and does not render correctly.
I tried the following but it does not work correctly:
$("#register-button").click(function(){
if (uname=="" || pname=="" || cemail=="" || remail=="") {
jAlert('Please fix the validation error','Title™');
return false;
}
});
As you can see, the only difference is that I've included ™
. However, it does not turn into ™ when the jAlert pops up.
How do I escape the jQuery in order for this entity to properly render?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在代码中的函数级别定义它:
现在您可以将其用作:
Just define this on function level in your code:
And now you can use it as: