admin管理员组文章数量:1424948
I use select2 with bootstrap3.
.html
Single select boxes
How to add search icon in search field?
like this:
/
This is my Select2 option code:
$(".select2").select2({
theme: 'bootstrap'
});
This is my HTML code:
<select style="width:100%" class="select2">
<optgroup label="Test-group">
<option>test1</option>
<option>test2</option>
</optgroup>
</select>
Thank you.
I use select2 with bootstrap3.
https://select2.github.io/examples.html
Single select boxes
How to add search icon in search field?
like this:
https://fk.github.io/select2-bootstrap-css/
This is my Select2 option code:
$(".select2").select2({
theme: 'bootstrap'
});
This is my HTML code:
<select style="width:100%" class="select2">
<optgroup label="Test-group">
<option>test1</option>
<option>test2</option>
</optgroup>
</select>
Thank you.
Share Improve this question edited Sep 5, 2016 at 15:50 Michael Benjamin 373k110 gold badges613 silver badges730 bronze badges asked Sep 5, 2016 at 2:55 manaovomanaovo 311 silver badge3 bronze badges2 Answers
Reset to default 3inspect your html and find the css rule of input, then add background to it like:
background: #fff url('select2.png') no-repeat 100% -22px;
This thread helped me - 8 years later there are slightly more options on how to do this, the one described below is what I ended up doing. This adds the placeholder value to the search bar inside of a select2 dropdown using jquery, using with bootstrap5.
$('#your-select-id').one('select2:open', function(e) {
$('input.select2-search__field').prop('placeholder', 'enter username or city');
});
ref: https://forums.select2/t/additional-placeholder-in-search-input/325
本文标签: javascriptSelect2 Search Icon on Search FieldStack Overflow
版权声明:本文标题:javascript - Select2 Search Icon on Search Field - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745417027a2657731.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论