Re: [jQuery] Are numerical properties/indexes supported?
On Jan 13, 2010, at 9:24 AM, Nathan Klatt wrote: On Wed, Jan 13, 2010 at 2:03 AM, Dean wrote: Any jQuery object currently has numerical properties/indexes that store references to the DOM node elements matched in the search. (E.g., $("div")[0] is a reference to the first matched DOM node element in the search.) Can we rely on these properties remaining in jQuery indefinitely? Every time $("div") is executed, it queries the DOM. If you want to save the results, save them: var divs = $("div"). Then, access them in the documented way: divs.eq(0). If brackets work now, as they are not mentioned in the documentation then, no, you can't count on that working in the future. Nathan Actually, I'm going to go out on a limb and say that you can count on the array notation staying in jQuery. By the way, divs.get(0) and divs[0] return the DOM node, but divs.eq(0) still returns the jQuery object. Also, jQuery is not an array at heart, but an array-like object. --Karl Karl Swedberg www.englishrules.com www.learningjquery.com
Re: [jQuery] Are numerical properties/indexes supported?
On Wed, Jan 13, 2010 at 2:03 AM, Dean wrote: > Any jQuery object currently has numerical properties/indexes that > store references to the DOM node elements matched in the search. > (E.g., $("div")[0] is a reference to the first matched DOM node > element in the search.) Can we rely on these properties remaining in > jQuery indefinitely? Every time $("div") is executed, it queries the DOM. If you want to save the results, save them: var divs = $("div"). Then, access them in the documented way: divs.eq(0). If brackets work now, as they are not mentioned in the documentation then, no, you can't count on that working in the future. Nathan
[jQuery] Are numerical properties/indexes supported?
Any jQuery object currently has numerical properties/indexes that store references to the DOM node elements matched in the search. (E.g., $("div")[0] is a reference to the first matched DOM node element in the search.) Can we rely on these properties remaining in jQuery indefinitely? (I haven't found reference to them in any documentation, but I suppose it could be that they are inherent to supporting other functions/ methods.)