加快“:not"速度IE 8中的jQuery CSS选择器? [英] Speed up ":not" jQuery CSS selector in IE 8?

查看:120
本文介绍了加快“:not"速度IE 8中的jQuery CSS选择器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IE中遇到性能问题,并且正在做一个带有此选择器的大型循环:

I am having trouble with performance in IE and I am doing a large loop that has this selector:

td:not(.some-cell)

在IE中有更有效的方法吗?

Is there a more efficient way to do this in IE?

推荐答案

IE8本身不支持:not选择器,因此,如果您使用的是jQuery内置的Sizzle之类的纯脚本选择器引擎,则可能是性能问题由于对所有元素的纯脚本搜索速度很慢.

IE8 does not support :not selector natively, so if you are using pure-script selectors engine like Sizzle built-in to jQuery, it may be performance issue due to slow pure-script search through all elements.

最简单的解决方案是在服务器端用特定的类标记每个TD元素,然后仅使用类选择器对其进行选择.

Most simple solution is to mark each that TD element with a specific class on server side, and then select them just with class selector.

<td class="not-some-cell"></td>

<script>
    // instead of $('TD:not(.some-cell)')
    var myCell = $('TD.not-some-cell');
</script>

这篇关于加快“:not"速度IE 8中的jQuery CSS选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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