7

非常实用的select下拉框-Select2.js

 3 years ago
source link: https://www.leixuesong.com/3146
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

非常实用的select下拉框-Select2.js

WEB前端 JS插件 2017年10月23日

Web开发中,Select下拉框是常用的输入组件。由于原生的Select几乎很难通过CSS样式控制。一些好看的Select下拉框就只能通过模拟来实现。雷雪松给大家推荐一筐款不错的Select下拉框插件:Select2。Select2可以支持搜索、标签、远程数据、无限滚动、和许多其他非常优秀的选项,Select2还可以非常方便的自定义样式,基本可以实现所有的Select效果。下面雷雪松就详细的讲解一下Select2.js的用法。

1、引入select2.js和select2.css

<link href="./select2.min.css" rel="stylesheet" />
<script src="./jquery.min.js"></script>
<script src="./select2.min.js"></script>

2、Select2基础用法

<select class="js-select2" name="job">
<option value="phper">PHP程序员</option>
<option value="web">web前端</option>
</select>
$(document).ready(function() {
$('.js-select2').select2();
});

Select2官方网站https://select2.org

来源:非常实用的select下拉框-Select2.js


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK