jQuery hoverIntent Plugin show / hide div on parent hover, but keep showing when hovered

前端 未结 1 1969
时光取名叫无心
时光取名叫无心 2021-01-26 04:25

I have a button that when hovered over (mouseover) displays a div right below it. When hovered away (mouseout), the div disappears.

This all works well and nicely, bu

1条回答
  •  心在旅途
    2021-01-26 05:08

    Stick another div #wrapperDiv around both the button and the #displayDiv and attach hoverIntent to #wrapperDiv rather than the button:

    $('#wrapperDiv').hoverIntent(function () {
       $("#displayDiv").stop().slideDown('slow');
    },
    function () {
       // I don't want the div to hide if user hovers over it
       $("#displayDiv").stop().slideUp('slow');
    });
    

    HTML:

    // some stuff
    // some other stuff that I want to // keep showing if users hover over it

    0 讨论(0)
提交回复
热议问题