当前第2页 返回上一页
默认样式,添加样式:data-style="class名"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | <select class = "selectpicker" data-style= "btn-primary" >
...
</select>
<select class = "selectpicker" data-style= "btn-info" >
...
</select>
<select class = "selectpicker" data-style= "btn-success" >
...
</select>
<select class = "selectpicker" data-style= "btn-warning" >
...
</select>
<select class = "selectpicker" data-style= "btn-danger" >
...
</select>
|
相关推荐:《bootstrap入门教程》
添加检索:data-live-search="true"
1 | <select class = "selectpicker" data-live-search= "true" >....</select>
|
Select多选:
添加“multiple ” 设置为多选,并且设置最多能选择2项 data-max-options="2"
1 | <select class = "selectpicker form-control" multiple data-max-options= "2" >...</select>
|
效果:
添加检索:data-live-search="true"
设置检索placeholder属性:data-live-search-placeholder="搜索"
添加“全选/反选” 功能按钮 data-actions-box="true"
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | <select class = "selectpicker" multiple data-live-search= "true" data-live-search-placeholder= "搜索"
data-actions-box= "true" >
<optgroup label= "filter1" >
<option>option1</option>
<option selected>option2</option>
<option>option3</option>
<option>option4</option>
</optgroup>
<optgroup label= "filter2" >
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
</optgroup>
<optgroup label= "filter3" >
<option>option1</option>
<option>option2</option>
<option>option3</option>
<option>option4</option>
</optgroup>
</select>
|
效果:
js初始化,设置选定的值
1 2 | $( '.selectpicker' ).selectpicker( 'val' , 'mustard' );
$( '.selectpicker' ).selectpicker( 'val' ,[ 'mustard' , 'relish' ]);
|
更新UI
1 | $( '.selectpicker' ).selectpicker( 'refresh' );
|
选中事件
1 2 | $( '.selectpicker' ).on( 'changed.bs.select' , function (e){
});
|
以上就是bootstrap的下拉多选框如何使用的详细内容,更多文章请关注木庄网络博客!
返回前面的内容
相关阅读 >>
bootstrap是不是js库
bootstrap与vue区别
bootstrap是什么,有什么特点?
bootstrap 怎么关闭弹出框
bootstrap怎么添加样式表
bootstrap的下拉多选框如何使用
bootstrap如何更改nav颜色
bootstrap用来做什么
bootstrap里面有什么东西
bootstrap模态框怎么用
更多相关阅读请进入《bootstrap》频道 >>
人民邮电出版社
本书对 Vue.js 3 技术细节的分析非常可靠,对于需要深入理解 Vue.js 3 的用户会有很大的帮助。——尤雨溪,Vue.js作者
转载请注明出处:木庄网络博客 » bootstrap的下拉多选框如何使用