Satinder singh
Satinder singh

Reputation: 10218

Jquery- Hide/Show a div after a duration on page load

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

Upvotes: 1

Views: 10769

Answers (2)

DGS
DGS

Reputation: 6025

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

Upvotes: 4

phuzi
phuzi

Reputation: 13079

setTimeout() accepts a callback and a duration and should be called like this:

setTimeout(function() {$(".startab").show()},4000);

Upvotes: 1

Related Questions