简体   繁体   English

如何设置div向下滑动并使用jquery向上滑动?

[英]how to set div slide down and slide up with jquery?

If news_img hover should be hide top to bottom else news_img show bottom to top. 如果news_img悬停应该从上到下隐藏,则news_img下到上显示。 I tried with this. 我尝试了这个。 jsfiddle 的jsfiddle

You can hide #news_img by default: 您可以默认隐藏#news_img

#news_img{ 
    display: none;
}

and use slideToggle() instead: 并改用slideToggle()

$(document).ready(function() {
    $("#news").hover(function(){
        $("#news_img").slideToggle();
    });
});  

Updated Fiddle 更新小提琴

Use jQuery .animate() . 使用jQuery .animate() Try this: 尝试这个:

$(document).ready(function() {
    $("#news").hover(function(){
        $('#news_img').animate({
            height: 'toggle'
            }, 290, function() {
        });  
    });      
});

DEMO DEMO

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

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