How do you remove a button's active state with jQuery Mobile?

后端 未结 8 1027
温柔的废话
温柔的废话 2020-12-03 07:31

In my mobile app, using jQuery Mobile...

  • I would like to make a simple button execute a simple javascript function on click. No page transitions, nothing sp

相关标签:
8条回答
  • 2020-12-03 08:21

    What I do is force the buttons to revert to inactive state before a page changes.

    //force menu buttons to revert to inactive state
    $( '.menu-btn' ).on('touchend', function() {
        $(this).removeClass("ui-btn-active");
    });
    
    0 讨论(0)
  • 2020-12-03 08:22
    If you want to support non touch devices you should add timeout.
    
    $('.btn' ).on('touchend click', function() {
        var self = this;
        setTimeout(function() {
                $(self).removeClass("ui-btn-active");
            },
        0);
    });
    
    0 讨论(0)
提交回复
热议问题