[英]select2 disable / enabled not working
I have a select element with select2 plugin. 我有一个带select2插件的select元素。 Version is 4.0. 版本是4.0。 It works well but i cant change disabled option dynamically. 它运作良好,但我无法动态更改禁用选项。
$('#list1').select2({
theme: "bootstrap",
disabled: true,
placeholder: "Parsel",
minimumInputLength: 0,
allowClear: true,
closeOnSelect: true,
});
As you can see, disabled is true. 如您所见,残疾是真的。 I cant change disabled option dynamically. 我无法动态更改禁用选项。 It work well if i delete disabled option. 如果我删除禁用选项,它工作得很好。
Im using this code for try to change option; 我正在使用此代码尝试更改选项;
$("#list1").select2({ disabled : false });
or 要么
$("#list1").select2('enable');
How can i change select element's disabled option ? 如何更改选择元素的禁用选项?
Thank you all. 谢谢你们。
Basic jQuery seems to solve this problem quite nice: 基本的jQuery似乎很好地解决了这个问题:
Enable: 启用:
$("#list1").removeAttr('disabled');
Disable: 禁用:
$("#list1").attr('disabled', true);
试试这个你需要的东西
$('#list1').select2("enable",true)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.