I'm trying to make a "select menu" ( selectmenu
) be reset when I enter a value by hand in a text field, but although I've tried countless solutions that I researched right here in Stack Overflow and other sites, none worked.
Below is my HTML code:
<div>
<label>Selecione Um Prazo Padrão:</label>
</div>
<div>
<select name="menuPrazo" id="menuPrazo" class="menuPrazo">
<option value="*" selected="selected">Escolha um Tipo de Prazo</option>
<option value="1">A Vista</option>
<option value="30">Prazo Normal</option>
<option value="15">Prazo Estendido</option>
</select>
</div>
<div>
<label>Ou Informe Um Prazo Personalizado:</label>
</div>
<div>
<input type="text" name="prazoManual" id="prazoManual" class="prazoManual" value=""></input>
</div>
Below the JavaScript code:
$(".menuPrazo").on("change", function () {
$("#prazoManual").val("");
});
$(".prazoManual").on("change", function () {
$('#menuPrazo').prop('selectedIndex',0);
});
In addition to the option contained in the code above, I've tried the following options:
$("select#menuPrazo").selectmenu("index", 0);
or
$("#menuPrazo").val("");
or
$("#menuPrazo").refresh();