javascript - 禁用 jQuery 按钮 - 仍然没有食谱

标签 javascript jquery-mobile

浏览互联网以查找如何禁用按钮:

<td valign="center" halign="left"><a href="#" id="save-user" data-role="button" data-inline="true" data-theme="b" data-icon="check">Save</a></td>

大多数食谱都没有结果:

$('#operator-modify').ready( function () {
// None of the below disable button
//$("#save-user").attr("disabled", true).button("refresh");
//$('#save-user').addClass('ui-state-disabled').attr('disabled', true);
//$('#save-user').attr('disabled', 'disabled').addClass( 'ui-state-disabled');
});

最后 - 如何启用/禁用按钮?

最佳答案

当您使用链接标记作为 button 时(即添加 data-role="button")JQM 按钮标记插件来应用按钮小部件标记/样式,但实际上创建按钮小部件。由于您实际上没有按钮小部件,因此您无法使用按钮小部件方法(启用、禁用等),而是要禁用或启用您的“按钮”,您需要添加/删除ui-disabled 类。

$('#save-user').addClass("ui-disabled");

这是一个简单的 jsBin

作为旁注,如果您不使用按钮进行导航,您可能需要使用表单按钮(inputbutton)(如果您确实使用常规按钮)那么您可以使用 JQM 按钮 disable方法。

关于javascript - 禁用 jQuery 按钮 - 仍然没有食谱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16086221/

相关文章:

html - 在 jquery mobile 中配置带有数字的自定义密码键盘

jquery - Cordova JQuery AJAX 不工作

android - JQuery Mobile 和谷歌地图故障

jquery-mobile - 在 jQuery Mobile 中删除 slider 控件中的文本框

javascript - 将物体设置成 Angular table

javascript - jQuery 和 Knockout 验证插件的 CSS 问题

javascript - MVC & JS : Using one form in a view and make it look like it's 2 views

javascript - 加载 iframe 后重新加载 iframe

asp.net-mvc - 将 ASP.NET MVC 布局应用于 Jquery.Mobile 页面的最佳实践

javascript - 如何使用 jQuery 设计事件链接列表项的样式