Select Disabled

by Carlos Quintero

HTML

<input type="text" id="opcion" placeholder="escriba la opcion"/>
<button id="agrega">Agregar</button><br><br>
<button id="habilita">Habilitar Select</button>
<button id="deshabilita">Deshabilitar Select</button><hr>
<select id="nuevo" disabled="disabled">
<option>Seleccione</option>
</select>

JavaScript

$(function(){
  $("#habilita").click(function(){
    $("#nuevo").removeAttr('disabled');
  })
    $("#deshabilita").click(function(){
    	$("#nuevo").attr('disabled','disabled');
  	})
    $("#agrega").click(function(){
    	var valor = $("#opcion").val();
    	$("#nuevo").append(`<option value="`+valor+`">
      `+valor+`</option>`);
      $("#opcion").val("");
    })
})