Reputation: 99
I've got this problem, I've a UL with some LIs and what I want it to do is: add the class "focused" when I enter the mouse in the LI and remove it to the previous one. So here is the code:
HTML:
<ul id="txtHint">
<li class="focusable focused">Jack</li>
<li class="focusable">Jone</li>
<li class="focusable">Junita</li>
<li class="focusable">Joleen</li>
<li class="focusable">Jeniffer</li>
<li class="focusable">Jacquie</li>
<li class="focusable">Jin</li>
</ul>
JQuery:
$("li.focusable").mouseenter(function () {
$("li.focused").removeClass("focused");
$(this).addClass("focused");
});
CSS:
.focused {
background-color: gray !important;
color: white;
}
I hope someone could find the problem! Here is the fiddle: http://jsfiddle.net/8qGNu/1/
Upvotes: 0
Views: 66
Reputation: 2098
use this css:
.focusable:hover {
background-color: gray !important;
color: white;
}
demo: http://jsfiddle.net/2EeB2/1/
Upvotes: 0