How do I disable a jqueryui button

2019-03-22 15:48发布

When I click on a jquery ui button, it still triggers the click event callback. How do I block that event? Do I have to manually keep track of the state or does jquery ui take care of that for me?

5条回答
相关推荐>>
2楼-- · 2019-03-22 15:50

Try this.

$('#button_id').button("disable");
$('#button_id').button("enable");
查看更多
在下西门庆
3楼-- · 2019-03-22 15:53

It's actually:

$("#btn").button({"disabled":true});
查看更多
你好瞎i
4楼-- · 2019-03-22 16:04

If you define like this:

$("#mybtn").button();

you must enable/disable like this:

$("#mybtn").button("enable");
// OR
$("#mybtn").button("disable");
查看更多
欢心
5楼-- · 2019-03-22 16:07

according the documentation:

// setter
$( "#button_id" ).button( "option", "disabled", true );
查看更多
看我几分像从前
6楼-- · 2019-03-22 16:07

It works for me:

$("#button_id").attr("disabled", true).addClass("ui-state-disabled");
查看更多
登录 后发表回答