jquery find to array

Solutions on MaxInterview for jquery find to array by the best coders in the world

showing results for - "jquery find to array"
Henri
13 Mar 2019
1<!doctype html>
2<html lang="en">
3<head>
4  <meta charset="utf-8">
5  <title>toArray demo</title>
6  <style>
7  span {
8    color: red;
9  }
10  </style>
11  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
12</head>
13<body>
14 
15Reversed - <span></span>
16 
17<div>One</div>
18 
19<script>
20function disp( divs ) {
21  var a = [];
22  for ( var i = 0; i < divs.length; i++ ) {
23    a.push( divs[ i ].innerHTML );
24  }
25  $( "span" ).text( a.join( " " ) );
26}
27 
28disp( $( "div" ).toArray().reverse() );
29</script>
30 
31</body>
32</html>
33