Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

jQuery Misc toArray() Method

❮ jQuery Misc Methods

Example

Convert the <li> elements to an array, then alert the innerHTML of the array elements:

$("button").click(function(){
  var 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 elements matched by the jQuery selector as an array.


Syntax

$(selector).toArray()

❮ jQuery Misc Methods