Enable select when selecting with jQuery

0

I did a perfunctory search on enabling select when choosing an option on another select , but I did not find anything that applied.

$(document).ready(function() {
  $('select#select1').select(function() {
    $('select#select2').prop('disabled', false);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><!doctypehtml><html><body><selectid="select1">
    <option>Opção 1</option>
    <option>Opção 2</option>
    <option>Opção 3</option>
  </select>

  <select id="select2" disabled>
    <option>Opção 1</option>
    <option>Opção 2</option>
    <option>Opção 3</option>
  </select>
</body>

</html>
    
asked by anonymous 10.11.2018 / 17:25

1 answer

2

Try to use $(...).on("change", ...) :

$(document).ready(function() {
  $('select#select1').on('change', function() {
    $('select#select2').prop('disabled', false);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><!doctypehtml><html><body><selectid="select1">
    <option>Opção 1</option>
    <option>Opção 2</option>
    <option>Opção 3</option>
  </select>

  <select id="select2" disabled>
    <option>Opção 1</option>
    <option>Opção 2</option>
    <option>Opção 3</option>
  </select>
</body>

</html>
    
10.11.2018 / 18:33