问题
I have a div which will display after some time .i.e on page load it will be invisible and after some duration it will be visible.
I tried this, but its not working for me.
setTimeout($(".startab").show(),4000);
$(".startab").delay(4000).show();
JS FIDDLE DEMO
回答1:
Need to use a closure
setTimeout(function () {
$(".startab").show()
}, 4000);
setTimeout takes a function as the first parameter and you were passing it an object
Fiddle
回答2:
setTimeout()
accepts a callback and a duration and should be called like this:
setTimeout(function() {$(".startab").show()},4000);
来源:https://stackoverflow.com/questions/18634783/jquery-hide-show-a-div-after-a-duration-on-page-load