1 line
1.2 KiB
JSON
1 line
1.2 KiB
JSON
{"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 - <span></span>\n\n<div>One</div>\n<div>Two</div>\n<div>Three</div>"},"longdesc":"\n <p><code>.toArray()</code> returns all of the elements in the jQuery set:</p>\n <pre><code>\nalert( $( \"li\" ).toArray() );\n </code></pre>\n <p>All of the matched DOM nodes are returned by this call, contained in a standard array:</p>\n <p>\n <span class=\"result\">[<li id=\"foo\">, <li id=\"bar\">]</span>\n </p>\n "}]} |