How to disable a link button in jQuery Mobile?

后端 未结 6 1159
被撕碎了的回忆
被撕碎了的回忆 2021-02-05 14:46

I have a jQuery Mobile Beta 1 website with jQuery 1.6.1 link button like this:

TEST         


        
6条回答
  •  南旧
    南旧 (楼主)
    2021-02-05 14:57

    Link button example:

    • http://jsfiddle.net/gRLYQ/6/

    JS

    var clicked = false;
    
    $('#myButton').click(function() {
        if(clicked === false) {
            $(this).addClass('ui-disabled');
            clicked = true;
            alert('Button is now disabled');
        } 
    });
    
    $('#enableButton').click(function() {
        $('#myButton').removeClass('ui-disabled');
        clicked = false; 
    });
    

    HTML

    
    

    NOTE: - http://jquerymobile.com/demos/1.0rc2/docs/buttons/buttons-types.html

    Links styled like buttons have all the same visual options as true form-based buttons below, but there are a few important differences. Link-based buttons aren't part of the button plugin and only just use the underlying buttonMarkup plugin to generate the button styles so the form button methods (enable, disable, refresh) aren't supported. If you need to disable a link-based button (or any element), it's possible to apply the disabled class ui-disabled yourself with JavaScript to achieve the same effect.

提交回复
热议问题