Jquery addClass and Remove Class on hover

前端 未结 4 1157
广开言路
广开言路 2021-01-02 18:34

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 hoverin

4条回答
  •  一生所求
    2021-01-02 18:56

    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/

提交回复
热议问题