Javascript examples for jQuery:List
Order a list of names alphabetically
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.5.2.js"></script> <script type="text/javascript"> $(window).load(function(){/* ww w .j a v a 2s . c om*/ var items = []; $('ul li').each(function(){ items.push($(this).html()); }) items.sort(); console.log(items) }); </script> </head> <body> <ul> <li>M</li> <li>J</li> </ul> </body> </html>