Append div content in reverse order with jQuery - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:append

Description

Append div content in reverse order with jQuery

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.js"></script> 
  <script type="text/javascript">
    window.onload=function(){//from  w w w .  j  a  va 2 s .c om
var data = [1, 2, 3, 4];
$.each(data, function(index, element) {
   $('.myDiv').prepend('<div>...SOME LONG HTML CONTENT - ' + index + '</div>');
});
    }

      </script> 
 </head> 
 <body> 
  <div class="myDiv"></div>  
 </body>
</html>

Related Tutorials