I am working Select2
Select-box.
Problem
Placeholder is not showing in select2
. It is always show the first option selected in the select2
. It's automatically select first option i want to show the placeholder instead of it.
My Code:
Script:
<script type="text/javascript">
$(document).ready(function () {
var data = $('#test_skill').select2({
placeholder: "Please select an skill",
allowClear: true
});
});
// I have also tried this: This is also not working
$('#test_skill').select2({
placeholder: {
id: '-1', // the value of the option
text: 'Please select an skill'
}
});
</script>
HTML:
<select class="skills_select2" required name="test_skill" id="test_skill">
<option value="1">TEST1</option>
<option value="2">TEST2</option>
<option value="3">TEST3</option>
</select>