$(document).ready(function() {
$(".desc").hide();
$(".products li").mouseover(function() {
$( this ).find( '.desc' ).show("fade");
});
$(".products li").mouseout(function() {
$( ".desc" ).hide("fade");
});
});

.products li{
width: 300px;
height: 300px;
border: 1px solid #808080;
display: inline-block;
margin: 5px;
transition: height 0.5s ease;
padding: 0px;
overflow: hidden;
background-size: 300px;
margin-left: -15px;
margin-right: 25px;
}
.products li p.desc {
background:#e4e4e4;
width: 280px;
height: 100px;
margin: 0px;
padding: 5px;
position: relative;
top: 200px;
padding-left: 10px;
padding-right: 10px;
text-align: justify;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<ul class="products">
<li><p class="desc">Short Description</p>
<li><p class="desc">Short Description</p>
</ul>
&#13;
我试图摆脱这个&#34;眨眼&#34;当您将li元素内的鼠标位置从li元素本身更改为其中的.desc元素时。上面的例子应该足够清楚。我希望你能帮助我。 THX。
答案 0 :(得分:1)
使用mouseenter()
和mouseleave()
关于jQuery事件:MouseOver / MouseOut vs. MouseEnter / MouseLeave
$(document).ready(function() {
$(".desc").hide();
$(".products li").mouseenter(function() {
$( this ).find( '.desc' ).show("fade");
});
$(".products li").mouseleave(function() {
$( ".desc" ).hide("fade");
});
});
.products li{
width: 300px;
height: 300px;
border: 1px solid #808080;
display: inline-block;
margin: 5px;
transition: height 0.5s ease;
padding: 0px;
overflow: hidden;
background-size: 300px;
margin-left: -15px;
margin-right: 25px;
}
.products li p.desc {
background:#e4e4e4;
width: 280px;
height: 100px;
margin: 0px;
padding: 5px;
position: relative;
top: 200px;
padding-left: 10px;
padding-right: 10px;
text-align: justify;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/themes/smoothness/jquery-ui.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.2/jquery-ui.min.js"></script>
<ul class="products">
<li><p class="desc">Short Description</p>
<li><p class="desc">Short Description</p>
</ul>
或使用.hover()
$(".products li").hover(function() {
$( this ).find( '.desc' ).show("fade");
},function() {
$( ".desc" ).hide("fade");
});