我有一个复选框,当页面上发生其他操作时,我需要启用和禁用该复选框。 使用 jquery-ui 更改了复选框,因此它看起来很漂亮。 这是伪代码:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.js"></script>
<script>
$(document).ready(function(){
$("#openchest").checkboxradio();
$("#enablebutton").click(function(){
$("#openchest").prop("disabled", false); // Doesnt work
$("#openchest").checkboxradio("enable"); // Also doesn't work
});
});
</script>
<button id="enablebutton">enable checkbox</button>
<label for="openchest"><input type="checkbox" id="openchest" disabled="disabled" value="1" />
我需要更改什么才能使按钮重新启用由 jquery-ui 初始化的复选框?