I am trying to make a placeholder like option in the select . The functionality will be like below -
The placeholder text will be shown as default
It will not appear in the dropdown
If you select an option then forward only the options will be showed.
What I am able to find is the below html segment is generated for showing the dropdown default text (which selects the first option) -
<div class="btn-group bootstrap-select">
<button
type="button"
class="btn dropdown-toggle selectpicker"
data-toggle="dropdown">
<span class="filter-option pull-left"></span> <span class="caret"></span>
</button>
<div class="dropdown-menu open">
<ul
class="dropdown-menu inner selectpicker"
role="menu">
</ul>
</div>
</div>
And somewhere in the code, inside the following html snippet
<span class="filter-option pull-left"></span>
the first element of the select element is put. Can anyone help me to find the exact line ?
You can add the data-hidden="true" attribute to the first option.
<select class="selectpicker" title="Some placeholder text...">
<option data-hidden="true"></option>
<option>Mustard</option>
<option>Ketchup</option>
<option>Relish</option>
<option>Onions</option>
</select>
Most helpful comment
You can add the
data-hidden="true"attribute to the first option.