兄弟,我写了一段代码,不知道能否帮到你,写的不好,谅解! 我是根据你的写法接着写的,多少还有bug,如果可以你自己再修改一下。你直接把代码粘帖到script下试试,代码如下:
$(function(){
var = 0;
$(".head").mouseenter(function(){
$(this).next().slideDown( 300 );
});
$(".content").mouseenter(function(){
= 1;
});
$(".content").mouseleave(function(){
$(this).slideUp(300);
= 0;
});
$(".head").mouseleave(function(){
setTimeout(function(){
if( == 1) {
return false;
}
$('.content').css('display','none');
= 0;
},20);
});
});
$(function(){
var = 0;
$(".head").mouseenter(function(){
$(this).next().slideDown( 300 );
});
$(".content").mouseenter(function(){
= 1;
});
$(".content").mouseleave(function(){
$(this).slideUp(300);
= 0;
});
$(".head").mouseleave(function(){
setTimeout(function(){
if( == 1) {
return false;
}
$('.content').css('display','none');
= 0;
},20);
});
});
<script type="text/javascript">
$( function () {
$( ".head" ).hover( function () { $( this ).next().slideDown( 300 ) });
$( '.fff' ).mouseleave( function () { $( '.content' ).slideUp(300) } );
} )
</script>
</head>
<body style="padding:30px">
<div class='fff' style="width:100px">
<div class="head">什么是jQuery?</div>
<div class="content">
asdfasd<br>
asdfasd<br>
asdfasd<br>
asdfasd<br>
asdfasd<br>
</div>
</div>
</body>
</html>