Sorting elements with jQuery using data attributes - Javascript jQuery

Javascript examples for jQuery:Data Attribute

Description

Sorting elements with jQuery using data attributes

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://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
  <script type="text/javascript">
    $(window).load(function(){/* w  w  w  . j av  a 2 s.  co m*/
function sortAscending(data_A, data_B)
{
    return (data_A - data_B);
}
var array =[ 9, 10, 21, 46, 19, 11]
array.sort(sortAscending)
console.log(array);
    });

      </script> 
 </head> 
 <body>  
 </body>
</html>

Related Tutorials