js(JQuery)引入select2

官方项目地址:https://select2.org/

引入css和js

<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/css/select2.min.css" rel="stylesheet" />
    <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.6-rc.0/js/select2.min.js"></script>
    <!-- select2 -->

使用

<select id="school" name="school" >
    <option value="小学">小学</option>
</select>
<script type="text/javascript">
$(‘#school‘).select2({  
      placeholder: ‘请选择学校‘  
    });
</script>

相关推荐