I have a html select like:
<select id="airports-sel">
<option data-group="1" value="1">Madrid–Barajas</option>
<option data-group="1" value="2">Torrejón de Ardoz Airport</option>
<option data-group="2" value="3">Milan-Malpensa</option>
<option data-group="2" value="4">Milan-Linate</option>
</select>
I need to add a new airport to this select using jQuery, I try to use the following code but it's not working:
$('#airports-sel').append($('<option>', {
value: 5,
text: Paris-Orly Airport,
data-group: 3
}));
This works without "data-group" but it's very important to me to have the data-group set on every option, can you please provide an example of how can I do this?