twitter-bootstrap 如何使用select2引导程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36132875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to use select2 bootstrap
提问by vicario
im new at select2 im using bootsrap v3.3.6
我是 select2 新手,我使用 bootsrap v3.3.6
how to plugin the select2 bootstrap? i already input
如何插入select2引导程序?我已经输入
<link href="css/select2.css" rel="stylesheet">
<link href="css/select2-bootstrap.css" rel="stylesheet">
<select id="position" style="width: 15%">
<option value=""></option>
<option>One</option>
<option>Two</option>
<script src="js/select2.js"></script>
$("#position").select2({
allowClear:true,
placeholder: 'Position'
});
but the output still like the default select2. not like bootstrap, please help
但输出仍然像默认的select2。不喜欢引导程序,请帮忙
回答by Zim
The $("#position").select2(..)instance should be inside scripttags. Make sure you close the selecttag. Make sure you're properly referencing the select2.css and select2.js and that there are no errors in the browser console.
该$("#position").select2(..)实例应该是里面script的标签。确保关闭select标签。确保您正确引用了 select2.css 和 select2.js,并且浏览器控制台中没有错误。
回答by Dev
Please update your code as follows:-
请按如下方式更新您的代码:-
<link href="css/select2.css" rel="stylesheet">
<link href="css/select2-bootstrap.css" rel="stylesheet">
<select id="position" style="width: 15%">
<option value=""></option>
<option>One</option>
<option>Two</option>
<script src="js/select2.js"></script>
<script>
$("#position").select2({
allowClear:true,
placeholder: 'Position'
});
</script>
Links are as follows:
链接如下:
https://cdnjs.com/libraries/select2
https://cdnjs.com/libraries/select2-bootstrap-css
https://cdnjs.com/libraries/select2?ref=driverlayer.com/web
Hope that helps!
希望有帮助!

