jquery slidedown on page load

2019-07-04 17:21发布

问题:

How can slide down a div with jquery on page load where css is set to display:none? I see a lot of solutions but none can slide div if css is set display:none. The best way is to hide it on load and after slidedown but the div have flash (show) when page is loading.

回答1:

You could try this:

$(document).ready(function(){
    $('.hidden').slideDown(1000);
});

HTML:

<div class="hidden">This is the content</div>

CSS:

.hidden{
 display:none;   
}

It slides down on page load.

DEMO



回答2:

$('#hidden_div_id').slideDown('slow');

this internally make use of display:block



回答3:

I didn't found above as working solution. So here it is http://www.robertprice.co.uk/robblog/using-jquery-to-scroll-to-an-element/

$('html, body').animate({
    scrollTop: ($('#element').offset().top)
},500);