Hover Item with JQuery

前端 未结 4 1381
名媛妹妹
名媛妹妹 2020-12-06 19:04

Is there a way to hover an element using javascript? I don\'t want to create another class, I just want to cause element to hover with javascript when my mouse pointer is no

4条回答
  •  生来不讨喜
    2020-12-06 20:04

    You can achieve this by addressing all of the items in your collection at the same time in your hover event handlers

    var items = $(".some-class-applied-to-many-different-items");
    items.hover(function() {
            // Mouseover state
            items.addClass("blah"); // <- for example
        },
        function() {
            // Mouseout state
            items.removeClass("blah");
    });
    

提交回复
热议问题