我有多个选择器,但我不知道如何更改所选项目的格式。有什么建议吗?
我阅读了this,找到了选项 selectedTextFormat ,但这不是我所需要的
$('.selectpicker').selectpicker({
selectedTextFormat: 'values'
});
答案 0 :(得分:0)
发现的解决方法
$(window).on('load', function() {
$('.selectpicker').selectpicker({
showSubtext: true
});
});
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.min.css">
<link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-select/1.5.4/bootstrap-select.min.js"></script>
<select class="selectpicker form-control" multiple>
<option data-subtext="Mustard" value="">1</option>
<option data-subtext="Ketchup">2</option>
<option data-subtext="Relish">3</option>
</select>