订单对象是否由指定的jQuery选择器返回? [英] Is the order objects are return by a jQuery selector specified?

查看:83
本文介绍了订单对象是否由指定的jQuery选择器返回?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所有jQuery选择器都返回一个对象数组.这些对象是否始终与HTML中的顺序相同?我可以依靠吗?

All jQuery selectors return an array of objects. Are these objects always in the same order as they are in the HTML? Can I rely on this?

推荐答案

是.
jQuery 1.3.2发行说明说:

按文档顺序返回的元素

这是对jQuery选择器引擎的一项更改,该更改将返回的结果重新排列为文档顺序,而不是传递选择器的顺序.此更改是为了符合Selectors API规范(jQuery在支持它的浏览器内部使用).

Elements Returned in Document Order

This is a change to jQuery's selector engine that re-orders the returned results to be in document order, instead of the order in which the selectors were passed in. This change was done in order to be in compliance with the Selectors API specification (which jQuery uses, internally, in browsers that support it).

jQuery 1.3 并非如此:

"a,b,c"样式选择器的顺序可能会更改.支持querySelectorAll的浏览器(Safari,Firefox 3.5 +,Opera 10 +,IE 8+)将按文档顺序返回元素,其他浏览器(当前)将按指定顺序返回元素.在1.3.2和更高版本中,所有以逗号分隔的选择器将按文档顺序返回.

The order of "a, b, c" style selectors may change. Browsers that support querySelectorAll (Safari, Firefox 3.5+, Opera 10+, IE 8+) will return the elements in document order, other browsers will (currently) return them in the order specified. In 1.3.2 and later release all comma-separated selectors will be returned in document order.

这篇关于订单对象是否由指定的jQuery选择器返回?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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