2012-06-06 75 views
0

我有一個簡單的代碼是這樣的:jQuery的動畫運行一次

<input id="Button1" type="button" value="button" />  
<table border="1" cellpadding="0" cellspacing="0" width="400px"> 
    <tr id="tr1"> 
     <td> 
      1 
     </td> 
     <td> 
      nima 
     </td> 
    </tr> 
    <tr id="tr2"> 
     <td> 
      2 
     </td> 
     <td> 
      agha 
     </td> 
    </tr> 
    <tr id="tr3"> 
     <td> 
      3 
     </td> 
     <td> 
      ligha 
     </td> 
    </tr> 
</table> 

,我寫這篇文章的代碼更改行一個背景

$(document).ready(function() { 
     $('#Button1').on('click', function() { 
      $('#tr1').stop() 
        .animate({ backgroundColor: "aqua" },800) 
        .stop() 
        .animate({backgroundColor: "white"},800); 
     }); 
    }); 

,但只運行一次,當我點擊再次在Button1沒有改變。哪裏有問題?

(我用jQuery.Color插件) 感謝

回答

2
$(document).ready(function() { 
    $('#Button1').bind('click', function() { 
     $('#tr1').animate({ backgroundColor: "aqua" },800) 
      .animate({backgroundColor: "white"},800); 
    }); 
});​ 

這個作品在谷歌瀏覽器...嘗試

+0

由於它不需要'stop'功能 – Arian

+0

如果確實需要停止功能,它只在第一個動畫之前需要一個,並且需要是.stop(true,true) –