簡體   English   中英

jQuery移動切換按鈕數據主題按鈕按下

[英]Jquery mobile toggle button data-theme on button press

我有某類的按鈕

<div class="prog-day">
    <div class="prog-clear" data-role="controlgroup" data-type="horizontal">
        <a href="#" data-role="button" data-mini="true" data-theme="b">Clear</a>
    </div>  
    <p></p>
</div    

我想切換主題顏色onclick。 切換ID發生變化,並且執行數據主題字母,但顏色沒有變化。 這是我根據其他帖子嘗試過的所有內容(觸發,創建,刷新)

$(".prog-day a").click(function() {
    console.log("clicked a day button");
    progToggle = $(this).attr("progToggle");
    if ( progToggle == "1"  ) {
        $(this).attr("data-theme","b").refresh;
        $(this).attr("progToggle","0");
        $(this).trigger('create');
        $(this).trigger('refresh');
        $('.prog-day p').html($(this).attr("progToggle")+$(this).attr("data-theme"));
        progToggle = $(this).attr("progToggle");
     }
     else {
        $(this).attr("data-theme","d").refresh;
        $(this).attr("progToggle","1");
        $(this).trigger('create');
        $(this).trigger('refresh');
        $('.prog-day p').html($(this).attr("progToggle")+$(this).attr("data-theme"));
        progToggle = $(this).attr("progToggle");
    }           
});

我在這里想念什么。 我最好跳過這些JQM樣式設置,而自己做嗎? 我實際上希望按鈕可以按下按下,而不是釋放。 也許您可以擺弄http://jsfiddle.net/PLx8v/3/

如果要檢查是否相等,請確保您的if語句具有3個相等的符號

if( progToggle === '1' ) {}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM