对于标记功能,我使用 bootstrap select2 插件。我有这样的标签
Process1,
Process2,
Process3,
Process4,
ALL
代码: http://jsfiddle.net/WQZUB/
如果用户选择“全部”,则不能允许他/她选择其他选项。
如何使用 bootstrap-select2
js 插件实现此功能?
提前致谢。
最佳答案
看这里:http://jsfiddle.net/WQZUB/1/
正如我在评论中所说:使用了“更改”事件
$(function() {
$('.select2_notifyAfter').select2({
placeholder: "Notify After",
allowClear: true
});
$('.select2_notifyAfter').on('change', function(e){
if( e.val.indexOf('4') >= 0 )
{
$('.select2_notifyAfter').select2("val", "4");
}
});
});
PS:我用了"4"
因为<option value="4">ALL</option>
关于javascript - jquery-select2 中的选择值验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21229052/