blazonix
blazonix

Reputation: 433

How do I call a jQuery script after a delay?

I'm having a bit of trouble doing this - I understand that we can delay running a function using the delay() function in jQuery, but what about if you want to delay calling a external jQuery script? I've found discussions pertaining to the previous problem, but not the latter. Excuse me if the questions seems overly simple - I've a complete newbie to jQuery.

Here's the piece of relevant code in my HTML page:

<script>
    $(document).ready(function () {
        $("div.logo").fadeIn(3000);
        $("div.logo").delay(1000).fadeOut(1500); // slideUp("slow")
    });
</script>

<script type="text/javascript">
    $(document).ready(function() {
        $('div.slider_class').queue();
    });
</script>

A quick description of what I'm trying to do is as follows:

  1. A box fades in, delays a while, and fades out.
  2. An s3slider gallery fades in, and features a slideshow of pictures.

I'd appreciate any pointers and suggestions...thanks! Baggio.

Upvotes: 0

Views: 297

Answers (1)

james246
james246

Reputation: 1904

$("div.logo").fadeIn(3000).delay(1000).fadeOut(1500, function(){
  // do your gallery fade here
});

That'll fade it in over 3 secs, wait another second, then fade it out over 1.5 seconds and then call whatever you put in the callback in fadeOut

Upvotes: 1

Related Questions