2012-07-07 54 views
1

我試圖讓我的代碼在動畫運行後跟隨鏈接。jQuery - .animate之後的鏈接

這個想法是,「Gnoll」擊中了你的按鈕,並且會將你發送到鏈接。

這是到目前爲止我的代碼:

它不是裏面的鏈接。

(另外,按鈕的顏色應該是通過「打」的動畫。到目前爲止,我已經失敗的一箇中途改變對)

$(document).ready(function(){ 


    $('.Homebutton').click(function(){ 

     $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');   
     $('.animateme').animate({ 
      left: '+=150', 
     }, 800, function() { 
      $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />'); 
     }); 
     $('.animateme').animate({ 
      left: '+=0', 
     }, 500); 

     $('.animateme').animate({ 
      left: '+=0', 
     }, 500, function() { 
      $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 
      }); 

    }); 

    $('#AddOnbutton').click(function(){ 
     $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');   
     $('.animateme').animate({ 
      left: '+=250', 
     }, 1000, function() { 
      $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />') 

     }); 
     $('.animateme').animate({ 
      left: '+=0', 
     }, 1000, function() { 
      $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 
      $("#AddOnbutton").html('<img src="Construct2/Images/redbutton.png" />'); 
      }); 


    }); 

}); 

的代碼是非常基礎,你可以看到。 鏈接應該最後

$('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 

回答

0

後觸發0.5秒我現在已經有點找到了自己:) 還不夠完善,但它的確定。

$('a.home').click(function(){ 
    var newLocation = $(this).attr('href'); 
     $('.animateme').html('<img src="Construct2/Images/Gnoll_Running.gif" />');   
     $('.animateme').animate({ 
      left: '+=150', 
     }, 800, function() { 
      $('.animateme').html('<img src="Construct2/Images/Gnoll_Hit.gif" />'); 
     }); 
     $('.animateme').animate({ 
      left: '+=0', 
     }, 500); 

     $('.animateme').animate({ 
      left: '+=0', 
     }, 500, function() { 
      $('.animateme') .html('<img src="Construct2/Images/Gnoll_Resting_smaller.gif" />'); 

      document.location = newLocation; 
      }); 
      return false;  
    });