【Select2】帶搜索框的下拉框美化插件


1  引入js css 文件

<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/select2.full.js"></script>
<link href="css/select2.css" rel="stylesheet" type="text/css">

 

2 html 代碼:

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>演示</title>
    <script src="js/jquery-1.11.1.min.js"></script>
     <script src="js/select2.full.js"></script>
     <link href="css/select2.css" rel="stylesheet" type="text/css">
  </head>
  <body>

  <div style="text-align:center;">
  <h2>select2 - 帶搜索的下拉框演示</h2>
  <br/>
    <select id='ss'>
      <option value="richerdyoung">richerdyoung</option>
    </select>
   </div>
    <script>
      //本地數據獲取    
      var data = [{ id: 'php', text: 'php' }, { id: 'python', text: 'python' }, { id: 'go', text: 'go' }];
      $("#ss").select2({
       data: data,
       placeholder:'請選擇',
       allowClear:true
      })
    </script>
  </body>
</html>

 

效果如下: 

 

 

演示地址:  https://www.richerdyoung.cn/select2/

 

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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM