I want to change the color of li which contains anchor when the mouse go over it, I make like this
-
Do it like this:
$("a[id='son']").hover(function(){
$(this).closest("li.sonItem").css("background-color","black");
});
NOTE: This will work ok, however you should never have more than 1 element with the same id (you can, but it's a very, very bad practice), it'd be better if you use a class, for example class="son"
, and your selector would be $("a.son")
.
Cheers