本文摘自PHP中文网,作者零下一度,侵删。
使用方法:
第一步引用样式以及相关JS
1 2 3 4 5 6 7 | <link rel= "stylesheet" href= "css/bootstrap.min.css?1.1.11" type= "text/css" />
<script type= "text/javascript" src= "js/jquery.min.js?1.1.11" ></script>
<script type= "text/javascript" src= "js/bootstrap.min.js?1.1.11" ></script>
<!-- Include the plugin's CSS and JS: -->
<script type= "text/javascript" src= "js/bootstrap-multiselect.js?1.1.11" ></script>
<link rel= "stylesheet" href= "css/bootstrap-multiselect.css?1.1.11" type= "text/css" />
|
第二步 构造Selection(注意 需要设置multiple属性,否则依然是单选模式,multiple="multiple" )
1 2 3 4 5 6 7 8 9 | <!-- Build your select : -->
< select class = "multiselect" multiple= "multiple" >
<option value= "cheese" >Cheese</option>
<option value= "tomatoes" >Tomatoes</option>
<option value= "mozarella" >Mozzarella</option>
<option value= "mushrooms" >Mushrooms</option>
<option value= "pepperoni" >Pepperoni</option>
<option value= "onions" >Onions</option>
</ select >
|
第三步 初始化插件:
1 2 3 4 5 | <script type= "text/javascript" >
$(document).ready(function() {
$( '.multiselect' ).multiselect();
});
</script>
|
常用方法:
select
$('#cid').multiselect('select', arr[i]); 给控件设置选中项
获取值
$('#cid').val();获取控件所有的选中值
以上就是bootstrap-multiselect 多选实例代码的详细内容!
相关阅读 >>
checkboxlist多选样式jquery、c#获取选择项
bootstrap-multiselect 多选实例代码
更多相关阅读请进入《bootstrap-multiselect》频道 >>
清华大学出版社
作者:[美]克里斯琴·内格尔(Christian Nagel)著。出版时间:2019年3月。
转载请注明出处:木庄网络博客 » bootstrap-multiselect 多选实例代码