jQuery DOM Element Method - toArray() Method

Example

Convert the li element to an array and then output the innerHTML of the array elements:

$("button").click(function() {
  x=$("li").toArray()
  for (i=0;i<x.length;i++)
    {
    alert(x[i].innerHTML);
    }
);

Try It Yourself

Definition and Usage

The toArray() method returns the jQuery selector matched elements in the form of an array.

Syntax

$(selector.toArray()