change jquery mobile color swatch dynamically

后端 未结 7 1112
隐瞒了意图╮
隐瞒了意图╮ 2020-12-17 18:13

I want to change a jquery-mobile buttons color swatch dynamically with javascript, but I can\'t\' find a way (except removing and adding all classes and event handlers, but

7条回答
  •  一生所求
    2020-12-17 18:40

    What worked for me is:

    //set button active
    $(this).parent().addClass('ui-btn-active');
    //set button inactive
    $(this).parent().removeClass('ui-btn-active');
    

    Adding the class 'ui-btn-active' to the parent will set the current button to active and change the data-theme to 'b'. This will not work for any arbitrary swatch though. So you may still need one of the longer solutions mentioned earlier.

提交回复
热议问题