使用单选按钮启用/禁用选择菜单,但在将 jQuery ui 组合框实现到我的选择框后,以下脚本不会隐藏 jQuery ui 选择框。如何启用/禁用 jQuery ui 组合框?
$(".parentcheck").click(function () {
var selectedmenu = $("#menu").val();
if ($(this).val() === "0") {
$("#parent").closest(".ui-widget").find("input, button" ).attr("disabled", true);
$("#parent").hide().find('option:selected').removeAttr('selected');
$("#menu").change();
}
if ($(this).val() === "1") {
$("#menu").change();
}
});
尝试了这条线,
$("#parent").closest(".ui-widget").find("input, button" ).attr("disabled", true);
还有
$("#parent").closest(".ui-widget").find("input, button" ).prop("disabled", true);
没有帮助
最佳答案
这里是 jQueryUI 的官方文档网站:
初始化后获取或设置禁用选项。
// getter
var disabled = $(".selector").autocomplete ("option", "disabled");
// setter
$(".selector").autocomplete ("option", "disabled", true);
关于javascript - 如何禁用精确 id 的 jQuery 函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7778173/