Bootstrap-Multiselect:如何使用 JQuery 取消选中和取消选中多选选项

use*_*ree 2 jquery twitter-bootstrap bootstrap-multiselect

我想编写 JQuery 代码,从 Bootstrap Multi select 中取消选中和取消选择某些选项。

例如,如果多选是选择并选中以下值: 在此处输入图片说明

我想要一个将输出以下内容的 JQuery

在此处输入图片说明

我做了以下无效的 JQuery:

    $('#example-optionClass').val('1').prop('checked', flase);
    $('#example-optionClass').val('4').prop('checked', flase);
    $('#example-optionClass').val('2').prop('checked', true);
    $('#example-optionClass').val('6').prop('checked', true);
Run Code Online (Sandbox Code Playgroud)

这里的源代码:

    $('#example-optionClass').val('1').prop('checked', flase);
    $('#example-optionClass').val('4').prop('checked', flase);
    $('#example-optionClass').val('2').prop('checked', true);
    $('#example-optionClass').val('6').prop('checked', true);
Run Code Online (Sandbox Code Playgroud)

请帮忙。谢谢

Jam*_*mes 7

在 MultiSelect 中选择您需要使用的选项

$('#example-optionClass').multiselect('select', ['2', '6']);
Run Code Online (Sandbox Code Playgroud)

这就是说从 example-optionClass 中选择选项“2”和“6”。

并取消选择您需要使用的选项

$('#example-optionClass').multiselect('deselect', ['1', '4']);
Run Code Online (Sandbox Code Playgroud)

这是说从 example-optionClass 取消选择选项“1”和“4”

如果您转到The Methods,您将看到所有可用的 JavaScript 方法,它更详细地解释了如何使用上述 2 个函数。

希望这可以帮助