1
$(document).ready(function(){
    $("#splash").fadeOut('6000');
    $.mobile.changePage("index.html");
});

I am new to jQuery and want to fade out the page with ID splash after it displays for about 5 seconds and then redirect it to the index page.

My problem is that the splash screen doesn't seem to stay on for more than a second even though I have specified the time.

j08691
  • 204,283
  • 31
  • 260
  • 272
  • Possible duplicate of [How to redirect to another page in jQuery?](http://stackoverflow.com/questions/503093/how-to-redirect-to-another-page-in-jquery) – Eli Sadoff Oct 25 '16 at 19:25

1 Answers1

3

As you've written it your second line won't wait for the first to finish. You can accomplish this with a callback:

$("#splash").fadeOut('6000', function(){
    $.mobile.changePage("index.html");
});

This executes $.mobile.changePage("index.html"); when the fadeOut finishes.

j08691
  • 204,283
  • 31
  • 260
  • 272