select2基本用法

1.介绍

select2 是一个可定制的复选框,支持查询,标签,远程的数据集,无线滚动和许多其他更高的使用选项。

2.官网

http://select2.github.io/

3.基本使用

  a.引入基本样式

    <script src="select2/select2.min.js"></script>

    <link href="select2/select2.css" rel="stylesheet" />

 b.编写html

  <select class="js-example-basic-single form-control" multiple="multiple">
            <option value="AL">Alabama</option>
            <option value="WY">Wyoming</option>
        </select>

 c.加载select2

      $(document).ready(function() {
                $(".js-example-basic-single").select2();
            });

select2包含了很多特性功能,查看更多例子: http://select2.github.io/examples.html

猜你喜欢

转载自liuwuhen.iteye.com/blog/2339829