Opera 10,jquery 与正则表达式替换
我有一个适用于除 Opera 之外的所有浏览器的 jquery 插件。触发了removeHighlight函数,但html没有改变。据我所知,IE、FF、Chrome 和 Safari 都按预期工作。
我的例子可以在这里找到: http://www.pritaeas.net/public/jquery/plugin-dev/< /a>
插件的 url 是: http://www.pritaeas.net/public/jquery/ plugin-dev/jquery.highlight.js
基本上,我只想删除具有特定类的所有 span 标签,保留文本不变。
谁能解释为什么 Opera 的反应不同,并提供解决方案或解决方法?
谢谢。
I have a jquery plugin that is working on all browsers, except opera. The removeHighlight function gets triggered, but the html is not changed. As far as I can see IE, FF, Chrome and Safari work as expected.
My example can be found here:
http://www.pritaeas.net/public/jquery/plugin-dev/
The plugin's url is:
http://www.pritaeas.net/public/jquery/plugin-dev/jquery.highlight.js
Basically, I just want to remove all span tags with a specific class, leaving the text as-is.
Can anyone explain why opera is responding differently, and provide a solution or work-around ?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
问题出在正则表达式中的
removeHighlight
函数中。我不知道为什么,但如果你的正则表达式是形式的,它就不起作用:尤其是第一个
.?
在这种情况下是有问题的。当您将其更改为.
或\"
时,您的正则表达式效果很好。您可以使用\"
形式,就像格式正确的 html all 一样属性应该用括号括起来,你也可以将它们添加到highlight
函数中:Problem is in your
removeHighlight
function, in regex. I don't know why, but your regex doesn't work if it is in form:especially first
.?
is problematic in this case. When you change it to.
or\"
, then your regex works great. You can use\"
form, as in correctly formatted html all attributes should be enclosed in parenthesis, and you can add them inhighlight
function too: