views:

30

answers:

1

Hi,

Is there some documentation 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 :)

+3  A: 

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

Mario Menger