What's going wrong with setTimeout?
Hi guys - I'm still very new to jQuery, I have the below code working fine:
- jQuery(document).ready(function($) {
- $(this).find('.logo').animate({ marginTop: '-296px',}, 1000);
- $(this).find('#one').animate({ opacity: 1,}, 2000);
- $(this).find('#two').animate({ opacity: 1,}, 2000);
- $(this).find('#three').animate({ opacity: 1,}, 2000);
- });
However, when I try to make it kick in two seconds after document ready it breaks entirely. Code below:
- jQuery(document).ready(function($) {
- setTimeout(function() {
- $(this).find('.logo').animate({ marginTop: '-296px',}, 1000);
- $(this).find('#one').animate({ opacity: 1,}, 2000);
- $(this).find('#two').animate({ opacity: 1,}, 2000);
- $(this).find('#three').animate({ opacity: 1,}, 2000);
- }, 2000);
- });
I'd like to know what I'm doing wrong. Bonus points to whoever can help me chain the animations (i.e., .logo gains its margin, #one gets its opacity, #two gets its opacity and then #three gets its opacity one after eachother).
Thanks!