简体   繁体   English

jQuery移动切换按钮数据主题按钮按下

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

I have a buttons of a certain class 我有某类的按钮

<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    

and I want to toggle the theme color onclick. 我想切换主题颜色onclick。 The toggle ID changes and does the data-theme letter but the color doesn't change. 切换ID发生变化,并且执行数据主题字母,但颜色没有变化。 This is all the things (trigger,create, refresh) I've tried based upon other posts 这是我根据其他帖子尝试过的所有内容(触发,创建,刷新)

$(".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");
    }           
});

What am I missing here. 我在这里想念什么。 Am I better off skipping this JQM stying stuff and just do it myself? 我最好跳过这些JQM样式设置,而自己做吗? I'd actually like the buttons to toggle on the down press, not the release. 我实际上希望按钮可以按下按下,而不是释放。 Perhaps you could fiddle with http://jsfiddle.net/PLx8v/3/ 也许您可以摆弄http://jsfiddle.net/PLx8v/3/

如果要检查是否相等,请确保您的if语句具有3个相等的符号

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM