jQuery.makeArray () method
Examples
A collection of HTML element into a corresponding array
$ (Function () {
var . elems = document getElementsByTagName ( "div "); // returns a list of nodes
var . arr = jQuery makeArray (elems) ;. arr reverse (); // method uses an array of elements of the list $ (Arr) appendTo (document body .);.})
try it"
Definition and Usage
$ .makeArray () Function is used to convert an object array-like a true array object.
Note: The class array of objects with attributes many of the array (for example, length attribute, [] array access operator, etc.), but it is after all not an array, the lack of inherited from the prototype object array of built-in methods (such as: pop (), reverse ()Wait).
grammar
$.makeArray( object )
参数 | 描述 |
---|---|
object | Object类型 需要转换为数组的类数组对象。 |
More examples
Into an array
Convert a jQuery object into an array.