JQuery ToArray

 

In this example The ToArray() method returns the elements matched by the jQuery selector as an array and it will be show on alert box

 
 
 
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script> <script> $(document).ready(function(){ $("button").click(function(){ var i; var x = $("li").toArray() for (i = 0; i< x.length; i++) { alert(x[i].innerHTML); } }); }); </script> </head> <body> <button style="border: 1px solid red; height: 40px; width:150px; font-size:17px; border-radius: 10px ">show value on alertbox</button> <ul style="color: palevioletred; font-size: 20px"> <li>Appwrk Design Team</li> <li>Appwrk Dev Team</li> <li>Appwrk Management Team</li> </ul> </body> </html>
Output