I'm trying to set the select option with jquery but it's not working properly. It actually set the value but the text is not updated.
I have tried with .prop('selected',true), .attr('selected',true), .prop('selected','selected'), .val() and .val().change() but nothig seems to work
Here is the select
<select class="input-field" id="equip_type" name="equip_type">
<option value="" disabled selected>Tipo de Equipo </option>
<option value="0">equip_type_other</option>
<option value="1">equip_type_desktop</option>
<option value="2">equip_type_laptop</option>
<option value="3">equip_type_tablet</option>
<option value="4">equip_type_printer</option>
</select>
I'm going to set the option within an ajax function, so the value came from the function. This is what I'm currently trying
$('#equip_type').val(data.equipType).change();
I have use the same method with other forms, but just this one is causing this truble. Is there something I'm missing?
$('#equip_type').val(data.equipType).trigger('change');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With