2012-07-08 83 views
2

我有這個代碼更改按鈕的點擊上一個顏色:按鈕變色點擊jQuery Mobile的

$('.fav').live('click', function(e) { 

    $(this).buttonMarkup({ theme: "b" }); 

}); 

我怎麼能再次點擊該按鈕返回到正常顏色(主題C)?

有沒有辦法看到按鈕的狀態?

回答

1

因爲它必須是活的,那麼你可以只讓自己的肘:http://jsfiddle.net/PLx8v/3/

+0

你能給我和樣品請:

自定義切換例子
$('.fav').live('click', function() { var dotoggle = $(this).attr("dotoggle"); if (dotoggle == "1" ) { $(this).buttonMarkup({ theme: "c" }); $(this).attr("dotoggle","0"); } else { $(this).buttonMarkup({ theme: "b" }); $(this).attr("dotoggle","1"); } }); 

的jsfiddle? – 2012-07-08 21:11:00

+0

必須是.live(),因爲按鈕通過ajax加載到列表中。該解決方案不起作用。 – 2012-07-08 21:36:00

+0

我已更新我的小提琴並回答使用.live。享受;) – Sindre 2012-07-08 22:22:06