为什么jQuery的父/最近(选择器)函数在IE8中表现不同? [英] Why does jQuery's parents/closest(selector) functions behave differently in IE8?

查看:127
本文介绍了为什么jQuery的父/最近(选择器)函数在IE8中表现不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个jQuery脚本,在Chrome 11和Firefox 4中运行得非常好,但它在IE8中似乎被打破了。它似乎与使用选择器使用 jQuery parents()函数有关。在IE8中运行时它不会返回任何元素。

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.

我创建了一个简化版本的问题,显示了相同的症状在jsFiddle上面,以防止大量的代码在这里。

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?

更新:使用 nearest()似乎会导致类似的行为,但在这种情况下似乎更合适。

UPDATE: Using closest() seems to result in similar behavior, but seems to be more suitable in this case.

推荐答案

顶级元素必须是部分吗?您似乎遇到了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.

浏览器中的部分支持。

这篇关于为什么jQuery的父/最近(选择器)函数在IE8中表现不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆