为什么 jQuery 的parents/closest(selector) 函数在 IE8 中表现不同?
我有一个 jQuery 脚本,在 Chrome 11 和 Firefox 4 中运行得很好,但在 IE8 中似乎无法正常工作。它似乎与使用 jQueryparents() 函数和选择器有关。在 IE8 中运行时它不会返回任何元素。
我创建了我的问题的简化版本,它显示了相同的症状在 jsFiddle,以防止这里有一大块代码。
谁能告诉我这里可能发生了什么?
更新:使用 closest() 似乎会导致类似的行为,但似乎更适合这种情况。
I have a jQuery script that works perfectly fine in Chrome 11 and Firefox 4, but it appears to be broken in IE8. It appears to be related to the use of the jQuery parents() function with a selector. It does not return any elements when run in IE8.
I've created a simplified version of my problem which shows the same symptoms over at jsFiddle, to prevent a big chunk of code here.
Can anybody tell me what might be going on here?
UPDATE: Using closest() seems to result in similar behavior, but seems to be more suitable in this case.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
顶级元素必须是部分吗?看起来您正在遇到 IE8 中缺乏对 HTML5 的支持限制您的领域之一。如果将这些部分更改为 div,则代码将按原样运行。
浏览器中的版块支持。
Do the top level elements have to be sections? It looks like you are running into one of the areas where the lack of support for HTML5 in IE8 is limiting you. If you change the sections to divs, the code works as is.
Section support in browsers.
看看 jsFiddle 中的选择器,如果我去掉选择器的第二部分,我就能让它在 IE8 中正常工作。
在每个选择器中,选择器后面都有一个“, fileparent”。没有必要像这样指定父级并删除它。事实上你可以完全摆脱 fileparent 。
Looking at the selectors in your jsFiddle, I was able to get it to work fine in IE8 if I just got rid of the second part of the selector.
In each of your selectors you had a ", fileparent" after the selector. It is not necessary to specify the parent like this and getting rid of it works. In fact you can get rid of fileparent all-together.