English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery Miscellaneous toArray() Method

jQuery Miscellaneous Methods

The toArray() method retrieves all elements that match the jQuery selector in the form of an array.

Syntax:

$(selector).toArray()

Example

Select all DIVs in the document and then return the DOM elements as an array:

let arr = $("div").toArray();
for (let i = 0; i < arr.length; i++) {
    alert(arr[i].innerHTML);
}
Test See‹/›

jQuery Miscellaneous Methods