简体   繁体   中英

How do I disable a jqueryui button

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?

Try this.

$('#button_id').button("disable");
$('#button_id').button("enable");

according the documentation:

// setter
$( "#button_id" ).button( "option", "disabled", true );

这个对我有用:

$("#button_id").attr("disabled", true).addClass("ui-state-disabled");

If you define like this:

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

you must enable/disable like this:

$("#mybtn").button("enable");
// OR
$("#mybtn").button("disable");

它实际上是:

$("#btn").button({"disabled":true});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM