Javascript examples for jQuery Method and Property:addClass
JQuery add count to class
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.1.js"></script> <style id="compiled-css" type="text/css"> div.selected {//ww w . j a va 2 s.c om background: red; } </style> <script type="text/javascript"> $(window).load(function(){ $("div[class^='item']").addClass('selected'); }); </script> </head> <body> <div class="item1"> 1 </div> <div class="item2"> 2 </div> </body> </html>