开发者

jquery: how are HTML elements ordered when I select them using jquery selector

开发者 https://www.devze.com 2023-01-11 00:12 出处:网络
Is there some docum开发者_运维技巧entation regarding the order of returned HTML elements by a jquery selector. So for example if I do

Is there some docum开发者_运维技巧entation regarding the order of returned HTML elements by a jquery selector. So for example if I do

$('div.experience_entries_list input.experience_order_array').each(function() 
{
    alert(this.value);
});

, can I assume that the returned elements will come in the order that they are positioned in the html? I've checked this and it seems to be so but I want to be 100% sure before releasing the code built with this assumption :)


Yes, as of jQuery 1.3.2 elements are returned in document order.

From the 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).

0

精彩评论

暂无评论...
验证码 换一张
取 消