我正在尝试禁用此按钮
<a data-role="button" id="next" data-icon="arrow-r" >Next</a>
点击事件不应触发,按钮 UI 也应反射(reflect)按钮禁用状态。
我尝试过以下方法
$("#next").attr('disabled',true);
$("#next").attr("disabled", "disabled");
$("#next").button('disable');
$("#next").button().button('disable');
似乎没有人能够同时解决这两个问题。
最佳答案
工作示例:http://jsfiddle.net/Gajotres/YFMsR/
不幸的是,只有 INPUT 按钮可以通过 button('disable')
禁用,因此您需要像这样模拟它:
$('#next').prop('disabled', true).addClass('ui-disabled');
Class ui-disabled
是一个用于禁用外观的 jQuery Mobile 类。
完整示例:
$(document).on('pagebeforeshow', '#index', function(){
// So we can test if button is disabled or not
$(document).on('click', '#next', function(){
alert('Click event');
});
$('#next').prop('disabled', true).addClass('ui-disabled');
});
如果您想了解更多信息,请查看此 article ,您会发现该主题的描述更加详细。
关于jquery - 禁用 jQuery 移动按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16855418/