{"name":"toArray","type":"method","title":".toArray()","deprecated":null,"removed":null,"desc":"Retrieve all the elements contained in the jQuery set, as an array.","categories":["miscellaneous/dom-element-methods","version/1.4"],"entries":[{"return":"Array","signatures":{"added":"1.4"},"examples":{"desc":"Select all divs in the document and return the DOM Elements as an Array; then use the built-in reverse() method to reverse that array.","code":"\nfunction disp( divs ) {\n var a = [];\n for ( var i = 0; i < divs.length; i++ ) {\n a.push( divs[ i ].innerHTML );\n }\n $( \"span\" ).text( a.join( \" \" ) );\n}\n\ndisp( $( \"div\" ).toArray().reverse() );\n","css":"\n span {\n color: red;\n }\n","html":"\nReversed - \n\n
.toArray() returns all of the elements in the jQuery set:
\nalert( $( \"li\" ).toArray() );\n \n All of the matched DOM nodes are returned by this call, contained in a standard array:
\n\n [<li id=\"foo\">, <li id=\"bar\">]\n
\n "}]}