1.1 select2插件基本使用
1、下载select2插件
1. 下载地址:https://github.com/select2/select2
2、官网地址:https://select2.org/getting-started/basic-usage
3、文件需要引入select2.full.js、select2.min.css(4.0.1版本)和jquery.1.8.3及以上
2、使用原有的 option
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta http-equiv="x-ua-compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Title</title> </head> <body> <select class="js-example-basic-single" name="state"> <option value="2">tom</option> <option value="18">naiqiang.xiao</option> <option value="19">jian.yang</option> </select> <link href="/static/select2/select2.css" rel="stylesheet" /> <script src="/static/jquery-1.12.4.js"></script> <script src="/static/select2/select2.js"></script> <script> $(document).ready(function() { $('.js-example-basic-single').select2(); }); </script> </body> </html>