繁体   English   中英

jQuery:在div1上的mousenter结束时显示div2

[英]jQuery: Show a div2 when mousenter over div1 is over

我有一个购物篮,当我在购物篮符号上进行叠放时,想显示一个产品列表。 但是,当我用鼠标离开购物篮徽标时,要将鼠标移到列表中,列表将消失(逻辑上)。 但是,我该怎么办,列表仍然显示并且仅在将鼠标移出列表框时消失? 这是我的代码:

<div id="basket" style="padding:10px; background-color:#00458b;color:white;position:relative;cursor:pointer; width: 130px;z-index:1000;">Basket</div>
<div id="list" style="padding:10px; background-color:#63a0df;color:white;position:relative; width: 200px; display: none;z-index:1100;" >
<ul id="products">

</ul>
<button type="button" class="unset">Destroy</button> 

</div>

$('#basket').bind({
        mouseenter: function() {

        $("#list").fadeIn("slow", function() {

        });
        },
        mouseleave: function() {
        $("#list").fadeOut('fast');
        }
    });

将您的块包装到通用div以便#list仍然可见,直到您从该通用div中退出

试试这个

<div id="basket" >
<div style="padding:10px; background-color:#00458b;color:white;position:relative;cursor:pointer; width: 130px;z-index:1000;">Basket</div>
<div id="list" style="padding:10px; background-color:#63a0df;color:white;position:relative; width: 200px; display: none;z-index:1100;" >
</div>

演示

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM