I have created a bootstrap selectpicker. But I want to show a place holder called Search here inside select picker input search. It seems my methods are not working.
I tried with this script. It doesn’t seem to affect
$(".selectpicker").selectpicker({
liveSearchPlaceholder: "Placeholder text"
});
Anyone know any solutions, please?
The snippet:
$(".selectpicker").selectpicker({
liveSearchPlaceholder: "Search here.."
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.5.3/js/bootstrap.bundle.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap-select.min.css">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap-select.js"></script>
<select class="selectpicker" data-show-subtext="false" data-live-search="true" style="-webkit-appearance: none;" data-live-search-placeholder="Search" >
<option value="" disabled selected class="disabled"></option>
<option value="ExhibitionPreparation">Exhibition Preparation</option>
<option value="Onlineserviceorderplatformandformssubmission">- Online service order platform and forms submission</option>
<option value="StandconstructionMachineandExhibitsetupmatters">- Stand construction. Machine and Exhibit set up matters</option>
</select>
2
Answers
i found this example "bootstrap-select with placeholder" try so: https://codepen.io/yakyrefael/pen/XRmVRG
Please, replace this code
by this one:
You can change ".selectpicker" by the id of a select if you want to set to it a specific placeholder.