Used by select2, select2

Source: Internet
Author: User

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"}]}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.