javascript - 如何禁用精确 id 的 jQuery 函数?

标签 javascript jquery jquery-ui autocomplete

使用单选按钮启用/禁用选择菜单,但在将 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/

相关文章:

javascript - jQuery悬停框关闭问题

javascript - 删除监视文件夹时 Node 监视 EPERM

javascript - 正则表达式,我怎么说,匹配除一个词以外的所有内容?

javascript - setTimeout 是使用回调时避免 stackoverflow 的有效方法吗?

javascript - 获取矩形内的地点谷歌地图

javascript - 样式标题工具提示在表格内不起作用

Javascript - 为每个字母添加一个跨度

javascript - Twitter Bootstrap 的拆分器

jquery - 使用 JQuery UI DatePicker 的日期范围 MVC 编辑器模板

jquery - 同时使用日期选择器和 jQuery 对话框功能