悬停时Jquery addClass和Remove Class

问题描述:

好的我想将鼠标 cfse_a 添加到元素 #searchput ,当鼠标悬停在元素,然后当鼠标悬停在元素上时,然后删除类 cfse_a

Okay i would like to add a class cfse_a to an element #searchput when the mouse is hovering over the element and then when the mouse is not hovering over the element then remove class cfse_a.

使用 addClass removeClass 方法:

Use hover event with addClass and removeClass methods:

$("#searchput").hover(function() {
    $(this).addClass("cfse_a");
}, function() {
    $(this).removeClass("cfse_a");
});

DEMO: http://jsfiddle.net/G23EA/