Javascript examples for jQuery:List
Displaying random number in LI
<html> <head> <script src="https://code.jquery.com/jquery-1.4.2.min.js"></script> <script> $(document).ready(function(){ var len = $("ul.contentBlock li").length; $("ul.contentBlock li").each(function(){ $(this).html(Math.floor(Math.random() * len)); });//from w w w. j av a2 s . co m }); </script> </head> <body> <ul class="contentBlock"> <li></li> <li></li> <li></li> <li></li> </ul> </body> </html>