jquery - 订单对象是否由指定的 jQuery 选择器返回?

标签 jquery

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

最佳答案

是的。
jQuery 1.3.2 release notes说:

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 上的情况并非如此:

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 - 订单对象是否由指定的 jQuery 选择器返回?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1636201/

相关文章:

jquery ajax项目重新加载后无法点击

javascript - jQuery 修复了在滚动时缩小到较小尺寸的导航栏是 super 马车

jquery - 使用不同的表数据重新加载已加载的 jqGrid

java - 无法使用ajax调用spring Controller

javascript - jQuery - bpopup 插件,我需要重现方面的帮助

javascript - 在 Wordpress 中保存 Widget 后 TinyMCE 消失

javascript - 忽略空白值对 json 进行排序

javascript - 函数在某些页面返回未定义

jquery - Chrome 扩展 : refuse header "date" in ajax request

javascript - 为什么html调用js函数会出现html找不到变量错误?