<http://jsfiddle.net/RBJ9R/1504/>
我希望mouseleave触发区域的大小增加,以包括图像以及原始鼠标中心区域(灰色框)。我希望用户能够仍然看到图像,如果他们鼠标移到图像区域。
谢谢!
#slender-trigger {
background-color: #CCC;
height: 100px;
width: 120px;
margin-left: 0px;
margin-top: 50px;
position: absolute;
}
#slender {
font-family: 'Strait', sans-serif;
height: 400px;
width: 400px;
border: thin dotted #F00;
position: absolute;
margin-top: 50px;
margin-left: 120px;
display: none;
}
<div class="purchasing-tips">
<div id="slender-trigger">nnnn</div>
<div id="slender" style="background-image:url(http://lorempixel.com/120/100/people); height: 100px; width: 120px; border: 1px solid black;">sadfasdf</div>
</div>
$("#slender-trigger").on("mouseenter", function() {
$("#slender").show();
}).on("mouseleave", function() {
$("#slender").hide();
});
答案 0 :(得分:3)
只需这样写:
$("#slender-trigger, #slender").on("mouseenter", function() {
$("#slender").show();
}).on("mouseleave", function() {
$("#slender").hide();
});