
使用bootstrap-select组件时,先引用下列文件
最后一个文件 defaults-zh_CN.min.js 非必需,是组件中文化的时候才需要引用。
<!-- Latest compiled and minified CSS --> <link min.css><!-- Latest compiled and minified JavaScript --><script></script><!-- (Optional) Latest compiled and minified JavaScript translation files --><script></script>
使用就更加简单了,不用任何已经js,直接使用class就可以初始化。
Select单选:
如果没有设置选中项,默认选中第一个option。如设置了tiltle属性,则显示title属性内容,不会默认选中。
<select> <option>广东省</option> <option>广西省</option> <option>福建省</option> <option>湖南省</option> <option>山东省</option> </select>

选项分组
<select> <optgroup> <option>广州市</option> <option>深圳市</option> <option>珠海市</option> </optgroup> <optgroup> <option>南宁市</option> <option>柳州</option> <option>桂林市</option> </optgroup> <optgroup> <option>烟台</option> <option>青岛</option> <option>济南</option> </optgroup> </select>

默认样式,添加样式:data-style="class名"
<select> ... </select><select> ... </select><select> ... </select><select> ... </select><select> ... </select>

相关推荐:《bootstrap入门教程》
添加检索:data-live-search="true"
<select>....</select>

Select多选:
添加“multiple ” 设置为多选,并且设置最多能选择2项 data-max-options="2"
<select>...</select>
效果:
添加检索:data-live-search="true"
设置检索placeholder属性:data-live-search-placeholder="搜索"
添加“全选/反选” 功能按钮 data-actions-box="true"
<select data-actions-box="true"> <optgroup> <option>option1</option> <option>option2</option> <option>option3</option> <option>option4</option> </optgroup> <optgroup> <option>option1</option> <option>option2</option> <option>option3</option> <option>option4</option> </optgroup> <optgroup> <option>option1</option> <option>option2</option> <option>option3</option> <option>option4</option> </optgroup></select>
效果:
js初始化,设置选定的值
$('.selectpicker').selectpicker('val','mustard');
$('.selectpicker').selectpicker('val',['mustard','relish']);
更新UI
$('.selectpicker').selectpicker('refresh');
选中事件
$('.selectpicker').on('changed.bs.select',function(e){
});











