2012-04-05 153 views

回答

1

這很簡單。

$(document).ready(function(){ 
var i=0; 
$('a#button').click(function(){ 
    $(this).toggleClass("down"); 
    if(i%2==0)$(this).html('divide by 2'); 
    else $(this).html('not divide by 2'); 
    i++;    
}); 
});​ 

使用變量,你可以檢查你的按鈕是什麼狀態。上面的代碼只是這種類型的狀態管理的原油。

檢查這個http://jsfiddle.net/LmULE/100/