select2 placeholder showing empty option
It's a late answer, but it can help someone.
I have modal with a select2 input.
We need to add <option></option>
for the placeholder to be shown.
HTML
<select id="Name">
<option></option>
<option value="John">John</option>
<option value="Brian">Brian</option>
<option value="Carl">Carl</option>
</select>
If I want the placeholder to appear.
Jquery
$('#Name').select2({placeholder: 'Select a Name'});
$('#Name').select2('val', '');
If I want to see a value on the select2 input:
$('#Name').select2('val', 'John');
The empty option is actually for placeholder, I solved it using the code below
var s1 = $('#select2id').select2({
multiple: true,
placeholder: "Select values"
});
s1.val([' ']).trigger("change");
the s1.val([' ']).trigger("change");
did the trick
You have a syntax error on 2nd line.
<option></option>