I read Learning jQuery 1.3 (Jonathan Chaffer and Karl Svedberg), and in the sort table they used .get() before calling .sort() and said
we need to convert jQuery objects to an array of DOM nodes. Although jQuery objects are very similar to arrays in many ways, they do not have available array methods such as .sort ().
the code:
$("#sort").click(function() { var posts = $("#posts_div .post"); posts.sort(function(a, b) { return ($(a).text()) > ($(b).text()); }); $.each(posts, function(index, post) { $("#posts_div").append(post); }); });
So, I tried to do this without using .get() , but was surprised that it worked even without .get() with the latest jQuery, but did not work with 1.3
So, we made some scripts to clarify
** Doesn't work without .get() jquery 1.2.6 **
Working with .get() jquery 1.2.6
Work without .get() jquery 1.7.2
Working with .get() jquery 1.7.2
So, is it obvious that previously jQuery objects did not use the .sort() function, the same as Javascript arrays? But now they ...
So my question is, what are the functions that jQuery objects do not yet support, so we can keep in mind converting to Javascript arrays before using
Rajat singhal
source share