.toArray()

Use .toArray() to convert elements to array


<!DOCTYPE html>
<html>
    <head>
        <script src="http://java2s.com/style/jquery-1.8.0.min.js">
        </script>
        <script >
            $(function(){<!-- www  .  j  a  v a 2s.  c  o m-->
                var winners = $( "#winners li" ).toArray();
                winners = winners.reverse();
                for ( var i = 0, test = winners.length; i < test; i++) {
                    document.writeln(winners[i].innerHTML);
                }
            });
        </script>
    </head>
    <body>
        <ol id="winners" >
            <li>A</li>
            <li>B</li>
            <li>C</li>
            <li>D</li>
            <li>java2s.com</li>
            <li>F</li>
            <li>G</li>
        </ol>
    </body>
</html>

Click to view the demo

The code above generates the following result.

.toArray()
Home »
  Javascript Tutorial »
    jQuery Reference »
      DOM
...
.insertBefore()
.is()
.last()
.map()
.next()
.nextAll()
.nextUntil()
.not()
.offset()
.offsetParent()
.outerHeight()
.outerWidth()
.parent()
.parents()
.parentsUntil()
.position()
.prepend()
.prependTo()
.prev()
.prevAll()
.prevUntil()
.remove()
.removeClass()
.removeAttr()
.replaceAll()
.replaceWith()
.siblings()
.scrollLeft()
.scrollTop()
.slice()
.text()
.toArray()
.toggleClass()
.unwrap()
.val()
.wrap()
.wrapAll()
.wrapInner()
...