Javascript examples for jQuery Method and Property:addClass
Javascript label div classes numerically
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.0.js"></script> <script type="text/javascript"> $(window).load(function(){//from ww w.j a va2s . c o m $('#main > div').addClass(function (i, clazz) { return '' + (i + 1) }) }); </script> </head> <body> <div id="main"> <div> 1 </div> <div> 2 </div> </div> </body> </html>