jquery: adding class on to list-items only on mouseover-remove on mouse-out?

Posted by user239831 on Stack Overflow See other posts from Stack Overflow or by user239831
Published on 2011-01-16T09:41:32Z Indexed on 2011/01/16 9:53 UTC
Read the original article Hit count: 188

Filed under:
|
|
|

hey guys, what's the best way to do that:

i have a list

<ul>
    <li>hello</li>
    <li>good bye</li>
    <li>arrivederci</li>
    <li class="selected">dude</li>
    <li>whatever</li>
</ul>

Initially one item already has a class of .selected applied. When i hover over one of the list-items i want this one to have the .selected class. So every item should only have the class applied when im over, as soon as i leave the item the class get's removed and the next one has the class.

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about hover