使用“:not”之间的性能差异和“.not()”选择器? [英] Performance differences between using ":not" and ".not()" selectors?
问题描述
以下两行之间有任何速度/效率差异。
$(table td:not(:first-child))
和
$(table td) .not(:first-child)
我会认为第一个会更好,因为它是删除对象,但有一个实际的差异,是实质性的。
感谢
取决于浏览器。
支持 querySelectorAll
的浏览器将提高性能。
$(table td:not(:first-child))
...因为它是一个有效的选择器。旧的浏览器(IE7及更低版本)不会。
您需要注意:not / code> selector。 jQuery(Sizzle)使用非标准选择器扩展它,因此很容易打破
qSA
。
Are there any speed/efficiency differences between the following two lines.
$("table td:not(:first-child)")
and
$("table td").not(":first-child")
I would think that the first would be better since it is removes objects, but is there an actual difference and is it substantial.
Thanks
Depends on the browser.
Browsers that support querySelectorAll
will get a performance boost with...
$("table td:not(:first-child)")
...because it is a valid selector. Older browsers (IE7 and lower) will not.
You need to be careful with the :not()
selector though. jQuery (Sizzle) extends it with non-standard selectors, so it's easy to break qSA
.
这篇关于使用“:not”之间的性能差异和“.not()”选择器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!