Chosen 有时需要选项互斥,比如以下示例,就是第一条和后面的全部数据互斥,因为第一条是全部数据,示例代码如下:
$("#bizChoosen").chosen().on("change", function (evt, arg) {
str = String($(this).val());//当前值
if(arg.selected){
if(str=="1"){//第一条的value
bizList.children('select').children('option').eq(0).siblings("option").attr("disabled", "disabled");
}else{
bizList.children('select').children('option').eq(0).attr("disabled", "disabled");
}
}else if(arg.deselected){
if(str==""){
bizList.children('select').children('option').removeAttr("disabled");
}else{
return ;
}
}
$("#bizChoosen").trigger("chosen:updated")
});
其中bizList是select的父元素。
如您从本文得到了有价值的信息或帮助,请考虑扫描文末的二维码对我进行赞赏和鼓励。
如本文对您有用,捐赠和留言 将是对我最好的支持~(捐赠可以转换为站内积分哦)
如愿意,请向朋友推荐本站,谢谢。
尊重他人劳动成果。 转载请务必附上原文链接,我将感激不尽。
有问题可以通过文末留言给我。
留言