Answers for "jquery find to array"

0

jquery find to array

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>toArray demo</title>
  <style>
  span {
    color: red;
  }
  </style>
  <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
 
Reversed - <span></span>
 
<div>One</div>
 
<script>
function disp( divs ) {
  var a = [];
  for ( var i = 0; i < divs.length; i++ ) {
    a.push( divs[ i ].innerHTML );
  }
  $( "span" ).text( a.join( " " ) );
}
 
disp( $( "div" ).toArray().reverse() );
</script>
 
</body>
</html>
Posted by: Guest on May-17-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language