Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

jQuery Misc toArray() Method

jQuery Misc toArray() Method

jQuery Miscellaneous Methods jQuery Miscellaneous Methods

Example

Puts the

  • Convert the elements to an array, then output the innerHTML of the array elements:

    $("button").click(function(){

    x=$("li").toArray()

    for (i=0;i

    {

    alert(x[i].innerHTML);

    }

    });

    Try it »


    Definition and Usage

    The toArray() method returns the elements matched by the jQuery selector as an array.


    Syntax

    $(

    selector

    ).toArray()


    jQuery Miscellaneous Methods jQuery Miscellaneous Methods