Jquery.sumoselect外掛實現下拉複選框
阿新 • • 發佈:2019-02-12
1、官方網站:
https://hemantnegi.github.io/jquery.sumoselect/ 說明介紹網址
https://hemantnegi.github.io/jquery.sumoselect/sumoselect_demo.html demo網址
2、實現效果
3、程式碼demo
首先引入js與css檔案
<link href="css/sumoselect.css" rel="stylesheet">
<script src="vendor/jquery.sumoselect.js"></script>
然後在html裡面新增select標籤:
<select multiple="multiple" placeholder="諮詢,建議" class="SlectBox" id="SlectBox" required style="width: 160px"></select>
最後在js程式碼中新增程式碼:
$('.SlectBox').SumoSelect({ csvDispCount: 3, captionFormat: '已選擇:{0}(個)', selectAll:true, captionFormatAllSelected: "全選", okCancelInMulti: true, locale : ['確定', '取消', ''] });
注意:官網中有許多的屬性,同時還能在select下拉框中繫結許多的事件:
當我們想要下拉框二級聯動的時候,通過下面的事件,重新整理select標籤中的內容實現下拉框的二級聯動。
//重新載入select標籤中的資料
$('#SlectBox')[0].sumo.reload();
在官網下載demo一看便知!