Ben*_*son 2 html css jquery jquery-hover
嗨我的代码有什么问题:
当我将鼠标悬停在#open #pull_down_content上时,应该从标题向下移动页面,当我离开#open时,它应该向上移动.但是当我在页面加载#pull_down_content时,我甚至将鼠标悬停在屏幕上时,我会立即测试代码.
$(function() {
//Open on hover
$('#open').hover((function(){
$('#pull_down_content').animate({'top':'-0px'},1000);
})
//Close when not hovered
(function(){
$('#pull_down_content').animate({'top':'-340px'},1000);
})
});
);
Run Code Online (Sandbox Code Playgroud)
Sel*_*gam 14
尝试修复您的功能,如下所示,
$(function() {
$('#open').hover(function(){ //Open on hover
$('#pull_down_content').animate({'top':'-0px'},1000);
},
function(){ //Close when not hovered
$('#pull_down_content').animate({'top':'-340px'},1000);
});
});
Run Code Online (Sandbox Code Playgroud)