0
I have a select:
<select class="form-control" id="dataInstalacao">
<option value="0/0" selected disabled>Quando podemos instalar?</option>
<option value="6/9">6/9</option>
<option value="7/9">7/9</option>
<option value="8/9">8/9</option>
<option value="9/9">9/9</option>
</select>
I use the following code to add more options :
var newOption = new Option("teste", data.id, false, false);
$('#dataInstalacao').append(newOption).trigger('change');
What happens is that when I inspect the element, the new option is there, but what is displayed on the screen is a list UL>LI
and select has display:none
and that list does not contain the new item.
How shall I proceed?
Wouldn’t it be simpler to do it this way?
$('#dataInstalacao').append(new Option('Foo', 'foo', true, true));
– João Pedro Schmitz