光年模板说明文档
主题
字号
18px

select2下拉

Select2 是一个优化下拉框 select 的 jQuery 插件,它支持搜索(搜索选择)、远程数据集、以及无限滚动的结果。这里集成的是4.0.10版本。

github地址:https://github.com/select2/select2

文档地址:https://select2.org/

需要增加以下的css。

.select2-container {
    width: 100%!important;
}

默认使用(引入相关的js和css后)

<div class="form-group">
  <label for="example-select">你是一名</label>
  <select class="form-control js_select2" name="example-1" id="example-select">
    <option value>请选择</option>
    <option value="1">平面设计</option>
    <option value="2">程序员</option>
    <option value="3">前端工程师</option>
    <option value="4">产品经理</option>
  </select>
</div>
$('.js_select2').select2();

插件项目中页面名字:test_select2.html test_select2_v4.html

点击查看 select2下拉选择框 在线演示

涉及的文件: