Used by select2, select2
I. Introduction
Select2 is a component used by Jquery to replace the selection box. It allows you to customize drop-down boxes and supports searching, tagging, remote data sources, unlimited scrolling, and other advanced features. For select2: https://select2.github.io /. The select2-4.0.0 version is used here. After downloading this version, decompress the file. The dist directory contains js and css files. To use select, You need to reference these files.
Ii. Use
1. Introduce jQuery and select2 styles and js files as follows:
<link href="css/select2.min.css" rel="stylesheet" /><script src="js/jquery.1.11.2.min.js"></script><script src="js/select2.min.js"></script><script src="js/i18n/zh-CN.js"></script>
Jquery is 1.11.2, where the zh-CN.js is a select2 localized file. Select2.min.css, select2.min. js and zh-Cn.js files are all files under the dist directory.
2. Example
<! DOCTYPE html>
For the dynamic rendering drop-down box, after the server is requested, the data returned by the server is json data. The json data format is as follows:
{"rows":[{"id":"10001", "name":"zhangsan"},{"id":"10001", "name":"zhangsan"},{"id":"10001", "name":"zhangsan"},{"id":"10001", "name":"zhangsan"},{"id":"10001", "name":"zhangsan"},{"id":"10001", "name":"zhangsan"}]}