I am using select2. My code is as like below.
<select class="form-control js-example-basic-multiple" name="list" multiple="multiple">
<option>Select a List</option>
<option>abcd</option>
<option>pqr</option>
<option>xyz</option>
</select>
I fetch some values from database and populate the select list. I am populating placeholder
also. In some cases I would not like to display placeholder
depending on the values of database. That’s why I would like to create placeholder from HTML.
I am using below code for placeholder.
$(document).ready(function() {
$('.js-example-basic-multiple').select2({
placeholder: "Select a List",
});
});
I am getting below output
In this case how can I display placeholder
?