I have two lists, When I hover on Tom in one-list I want the description about him to go red so I have added a class of hover as shown below. The problem I am having is I can't remove the hover state as I am getting undefined when I am leaving the hover state. I have commented out the few things I have tried so far. Is there a way to either know the value of id or remove any class called hover on the page when I leave the hover?
<ul id="one-list">
<li id="u11">Tom</li>
<li id="u22">Jerry</li>
</ul>
<ul id="another-list">
<li id="a11">Tom is 22 years old</li>
<li id="a22">Jerry is 18 years old</li>
</ul>
$("#one-list li").hover(
function () {
var id = jQuery(this).attr('id') || '';
id = id.replace(/u/, '');
$('#another-list #a' + id ).addClass("hover");
}, function () {
//$('body').removeClass("hover");
//$('#another-list #a' + id ).removeClass("hover");
}
);
.hover {
color:red;
}