I'm using jquery 1.5 and I'm having an issue with the add and remove class function . Below is my code.
I'm creating a navigation with a normal, hover, and active state. The active state I want to add and remove the class.
$(".class").hover(function(){
$(this).css("background-color", "#666).css("color", "yellow");
), function(){
$(this).css("background-img", url(image).css("color","#fff");
).live('click', function(){
if($("ul.me li").hasClass("current")){
$("ul.me li").removeClass("current");
$(this).addClass("current");
}
});
<ul class="me">
<li class="current"> item1 </li>
<li> item1 </li>
<li> item1 </li>
</ul>
Did I bind this on correctly?
You probably need to use
$("ul.me li").removeClass("current")instead of$("ul#me li").removeClass("current")