简体   繁体   中英

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. I tried with this. jsfiddle

You can hide #news_img by default:

#news_img{ 
    display: none;
}

and use slideToggle() instead:

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

Updated Fiddle

Use jQuery .animate() . Try this:

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

DEMO

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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