bootstrap multiselect下拉列表功能

荣誉就像河流:轻浮的和空虚的荣誉浮在河面上,沉重的和厚实的荣誉沉在河底里。学会忽略,是通向内在平静的一条大路。早上好!

bootstrap-multiselect基于原生态的下拉列表添加更多的功能及更好的视觉效果!

1、源码地址

https://github.com/davidstutz/bootstrap-multiselect

2、效果展示


3、代码示例

引入的js和css

<script src="js/jquery-1.11.3.js"></script> 
    <script src="js/bootstrap.js"></script> 
    <link rel="nofollow noopener noreferrer" href="css/bootstrap.css" rel="external nofollow" rel="stylesheet" /> 
    <script src="js/bootstrap-multiselect.js"></script> 
    <link rel="nofollow noopener noreferrer" href="css/bootstrap-multiselect.css" rel="external nofollow" rel="stylesheet" /> 
    <script src="~/Scripts/Home/Index_davidstutz.js"></script> 

实现代码

3.1、多选站点

<label class="control-label col-xs-1" for="sel_search_orderstatus">多选站点</label> 
  <div class="col-xs-2" style="margin-top:7px;"> 
    <select id="sel_search_orderstatus" style="width:350px;"  multiple="multiple"> 
      <option value="0">未排产</option> 
      <option value="5">已排产</option> 
      <option value="10">已锁定</option> 
      <option value="25">在制</option> 
      <option value="20">订单提交</option> 
      <option value="30">订单删除</option> 
      <option value="50">订单报废</option> 
      <option value="50">订单报废</option> 
      <option value="50">订单报废</option> 
      <option value="50">订单报废</option> 
      <option value="50">订单报废</option> 
       
    </select> 
  </div> 
$(function () { 
      $('#sel_search_orderstatus').multiselect({ 
        includeSelectAllOption: true}); 
      }); 

3.2、禁止和默认选中

<label class="control-label col-xs-1" for="sel_search_orderstatus2">disabled Select</label> 
  <div class="col-xs-2" style="margin-top:7px;"> 
   <select id="sel_search_orderstatus2" style="width:150px" multiple="multiple"> 
      <option value="0">未排产</option> 
      <option value="5" selected="selected">已排产</option> 
      <option value="10" selected="selected">已锁定</option> 
      <option value="25" disabled="disabled">在制</option> 
      <option value="20" disabled="disabled">订单提交</option> 
      <option value="30" disabled="disabled" selected="selected">订单删除</option> 
      <option value="50">订单报废</option> 
    </select> 
  </div> 
$(function () { 
      $('#sel_search_orderstatus2').multiselect(); 
      }); 

3.3、分组

<label class="control-label col-xs-1" for="sel_search_orderstatus3">分组</label> 
            <div class="col-xs-2" style="margin-top:7px;"> 
              <select id="sel_search_orderstatus3" style="width:150px" multiple="multiple"> 
                <optgroup label="未上线" > 
                  <option value="0">未排产</option> 
                </optgroup> 
                <optgroup label="已上线"> 
                  <option value="5">已排产</option> 
                  <option value="10" selected="selected">已锁定</option> 
                  <option value="25" disabled="disabled">在制</option> 
                  <option value="20">订单提交</option> 
                </optgroup> 
                <optgroup label="异常"> 
                  <option value="30">订单删除</option> 
                  <option value="50">订单报废</option> 
                </optgroup> 
              </select> 
            </div> 
$(function () { 
       $('#sel_search_orderstatus3').multiselect( 
        ); 
      }); 

3.4、单选项

<label class="control-label col-xs-1" for="sel_search_orderstatus3">单选</label> 
    <select id="example-single"> 
      <option value="1">Option 1</option> 
      <option value="2">Option 2</option> 
      <option value="3">Option 3</option> 
      <option value="4">Option 4</option> 
      <option value="5">Option 5</option> 
      <option value="6">Option 6</option> 
    </select> 
$('#example-single').multiselect(); 

3.5、搜索

<label class="control-label col-xs-1" for="sel_search_orderstatus3">搜索</label> 
    <select id="example-getting-started" multiple="multiple"> 
      <option value="cheese">Cheese</option> 
      <option value="tomatoes">Tomatoes</option> 
      <option value="mozarella">Mozzarella</option> 
      <option value="mushrooms">Mushrooms</option> 
      <option value="pepperoni">Pepperoni</option> 
      <option value="onions">Onions</option> 
    </select> 
$(function () { 
       $('#example-getting-started').multiselect({ 
          includeSelectAllOption: true, 
          enableFiltering: true 
        }); 
 }); 

默认无滚动条,请在bootstrap-multiselect.css中添加即可。

具体属性demo,源码解释的非常清楚,我就不列出来了。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。

您可能有感兴趣的文章
bootstrap select2 动态从后台Ajax动态获取数据的代码

MVC遇上bootstrap后的ajax表单验证

浅谈Bootstrap的DatePicker日期范围选择

bootstrap datepicker的基本使用好代码教程

Bootstrap 时间日历插件bootstrap-datetimepicker配置与应用小结