Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"Untitled"
Bootstrap 3.3.0 Snippet by
calvin52019
3.3.0
Preview
HTML
CSS
JS
View Full Screen
Fork
Fork this
992
 
0 Fav
Post to Facebook
Tweet this
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!-- Bootstrap --> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous"> <link rel="stylesheet" href="http://www.jq22.com/demo/bootstrapselect201901090009/css/bootstrap-select.css"> <!-- jQuery (necessary for Bootstrap's JavaScript plugins) --> <script src="https://code.jquery.com/jquery-1.12.4.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script> <!-- Include all compiled plugins (below), or include individual files as needed --> <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script> <script src="http://www.jq22.com/demo/bootstrapselect201901090009/js/bootstrap-select.js"></script> <div class="container"> <div class="row"> <div class="col-md-12"> <h2 class="text-center">Bootstrap multi-select</h2> </div> </div> <div class="row"> <div class="col-md-4"> <button id="showInfo" type="button" class="btn btn-success btn-lg btn-block">SHOW</button> </div> <div class="col-md-4"> <button id="hideInfo" type="button" class="btn btn-danger btn-lg btn-block">HIDDEN</button> </div> <div class="col-md-4"> <button id="chooseText" type="button" class="btn btn-warning btn-lg btn-block">Selected Information</button> </div> </div> <div class="row"> <div class="col-md-6 col-md-offset-4"> <select id="id_select" class="selectpicker" multiple data-live-search="true" data-actions-box="true"></select> </div> <div class="col-md-6 col-md-offset-4"> <label class="m-t-20 m-l-30 text-info">Selected Information:</label> <p id="labelInfo" class="m-t-5 m-l-50"></p> </div> </div> </div>
.m-t-20 { margin-top: 20px; } .m-l-30 { margin-left: 30px; } .m-t-5 { margin-top: 5px; } .m-l-50 { margin-left: 50px; }
init(); function init() { // initInfo(); } function loadInfo() { // 默认数据 var area = document.getElementById("id_select"); area.options.length = 0; result = { "6": "湖南", "7": "江苏", "8": "江西", "9": "广东", "10": "重庆", "11": "广西", "17": "浙江", "18": "湖北", "19": "山东", "20": "陕西" }; for (var item in result) { area.options.add(new Option(result[item], result[item])); } $('.selectpicker').selectpicker('refresh'); } function initInfo() { $(window).on('load', function () { $('.selectpicker').selectpicker({ // 'selectedText': 'cat', noneSelectedText: '请选择', noneResultsText: '没有找到匹配的组织 {0}' }); loadInfo(); $("#showInfo").unbind("click").click(function () { $('.selectpicker').selectpicker('show'); }); $("#hideInfo").unbind("click").click(function () { $('.selectpicker').selectpicker('hide'); }); $("#chooseText").unbind("click").click(function () { var info = $('#id_select').selectpicker('val'); var label = document.getElementById("labelInfo"); label.innerHTML = info; console.log(info) }); // 检测浏览器的方法由用户自行决定 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent)) { $('.selectpicker').selectpicker('mobile'); } // 销毁: $('.selectpicker').selectpicker('destroy'); }); }
Related:
See More
Template
Vue Material Kit PRO
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76