.toArray()
In this chapter you will learn:
Use .toArray() to convert elements to array
<!DOCTYPE html><!--from j a va2 s.c o m-->
<html>
<head>
<script src="http://java2s.com/style/jquery-1.8.0.min.js">
</script>
<script >
$(function(){
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>
Next chapter...
What you will learn in the next chapter: