使用JQuery禁用JQuery Mobile按钮

前端之家收集整理的这篇文章主要介绍了使用JQuery禁用JQuery Mobile按钮前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的 JQuery移动按钮.这可能很简单.我能够禁用一个HTML按钮,但我似乎无法用这个标记得到它.
<a href="" data-role="button"  class="answer_but" id="a" data-theme="b" data-answer="1">

这可能很简单.谢谢

解决方法

Disable Buttons in jQuery Mobile

实况示例:http://jsfiddle.net/XRjh2/16/

更新:

链接按钮示例:

> 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

<div data-role="page" id="home">
    <div data-role="content">

        <a href="#" data-role="button" id="myButton">Click button</a>
        <a href="#" data-role="button" id="enableButton">Enable button</a>

    </div>
</div>

注意: – 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.

猜你在找的jQuery相关文章