javascript - jQuery addClass() / removeClass() not working -


<ul>     <li class="selected"></li>     <li></li>     <li></li> </ul> 

that html. , selectors using right are:

    $("ul li:eq(0)").removeclass('selected');     $("ul li:eq(1)").addclass('selected'); 

problem can not add or remove 'selected' class these elements. html , jquery both pretty straight-forward , many examples find did same way, including official jquery docs. (the script loaded before body tag, if matters)

why can't remove , add classes this?

the entire html page here

probably because forgot add $(document).ready() ,also make sure added jquery.min.js file

$(document).ready( function () {     $("ul li:eq(0)").removeclass('selected');     $("ul li:eq(1)").addclass('selected'); }); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -