【问题标题】:How to disable all the checkboxes inside jquery multiselect如何禁用jQuery多选中的所有复选框
【发布时间】:2012-10-01 13:58:22
【问题描述】:

在 jQuery 中,如何禁用多选中的所有复选框。

【问题讨论】:

标签: jquery multi-select


【解决方案1】:
$("input[type=checkbox]:not(:checked)").attr("disabled", "disabled")

这很好用,但考虑将操作限制在页面的给定部分可能会起作用。取消选中所有复选框现在可能没问题,但稍后您可能会向页面(或其他任何内容)添加更多内容,因此取消选中所有复选框可能不正确或错误。

为每个复选框指定一个类,或者您可以使用它来限制对给定容器的操作

$(".example_container").find("input[type=checkbox]:not(:checked)").attr("disabled", "disabled")

【讨论】:

  • 我知道了 $("#multiselectelement").multiselect("widget").find(':checkbox').attr('disabled'‌​,'true');
【解决方案2】:
$("input[type=checkbox]:not(:checked)").attr("disabled", "disabled")

【讨论】:

  • $("#multiselectelement").multiselect("widget").find(':checkbox').attr('disabled'‌​,'true');
【解决方案3】:
$('input[type=checkbox]:not(:checked)').attr('disabled', 'disabled');

【讨论】:

  • 我知道了 $("#multiselectelement").multiselect("widget").find(':checkbox').attr('disabled','true');
【解决方案4】:

使用

  $("input:not(:checked)").attr("disabled", "disabled");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-03
    • 1970-01-01
    • 2017-09-09
    • 1970-01-01
    • 2019-03-05
    • 1970-01-01
    • 2016-11-06
    • 1970-01-01
    相关资源
    最近更新 更多