CodeIgniter Forums
jquery add class failed when the page loaded - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: jquery add class failed when the page loaded (/showthread.php?tid=47464)



jquery add class failed when the page loaded - El Forum - 12-09-2011

[eluser]Unknown[/eluser]
hello CI's masters, i wonder why when i'm adding a class to a li tag using jquery, the class only appears just a while and then gone. here's my code.
the JS
Code:
$(document).ready(function() {
$("ul.tab li").click(function() {
  $("ul.tab li").removeClass("active"); //Remove the active class
  $(this).addClass("active"); //Add the active tab to the selected tab
  
});
});

the HTML
Code:
<ul class="tab">  
   <li class="active nap"></li>
   <li class="nap"></li>
   <li class="nap"></li>
   <li class="nap"></li>
   <li class="nap"></li>
</ul>
if you argue that why i'm not using
Code:
echo anchor tag
, i've used it, and nothing happens.
any typo maybe?