Mouseout on specified divs and keep original div open

后端 未结 2 1048
别跟我提以往
别跟我提以往 2021-01-25 08:27

I\'m trying to do this in plain english: I have an open div from a mouseover event, when I take the mouse out of the div it closes on mouse out, perfect. What I need is that whe

2条回答
  •  -上瘾入骨i
    2021-01-25 09:09

    Why don't you simply keep your simple hover logic as it is (hide on mouse out) but then simply re-show it when the mouse is over the X or Y div.

    $('#openDiv').mouseout(function() {
        $(this).hide();
    });
    
    $('div.x').mousein(function() {
        $('#openDiv').show();
    });
    

    If you make your $('div.x') selector have an ID or at least a context that isn't the entire DOM, I bet the "flicker" from hiding then showing again isn't even noticeable.

提交回复
热议问题