$(document).ready(function() {
$("#div1").fadeIn("slow");
$("#div2").delay(500).fadeIn("slow");
$("#div3").delay(2000).fadeIn("slow");
$("#div4").delay(8000).fadeIn("slow");
});
This is my current setup but I feel like this isn’t the best way to write this. I can’t find any examples on how you would write this better for timing. Any help? I’d appreciate it.
I should also add that the timing of each element isn’t consistent.
fadeIntakes a callback as its second parameter. That callback is executed as soon as the animation is complete. If you want the elements to fade in sequentially, you could chain the callbacks:This could be re-written using an array of selectors and a single method, if you felt like it:
See this last one in action at JSBin.