Topic: Selected option of material select jquery

Sara Rodríguez free asked 7 years ago


Hi! I want to set a option when the modal has been shown, but it's not working. This is my code javascript: $('#modalDireccionesPerfil').on('show.bs.modal', function (e) { $('#prueba').val("1"); }); What I'm doing wrong? Thanks

Sara Rodríguez free commented 7 years ago

This is my select: <select id="prueba" name="prueba" class="mdb-select pr-4"> <option value="0">Ninguno</option> <option value="1">Valor 1</option> <option value="2">Valor 2</option> </select>

Mikołaj Smoleński staff answered 7 years ago


Hi Sara, The code $(‘#prueba’).val(“1”) is correct, but that part is wrong: .on(‘show.bs.modal’. For example, You should call that function when You click the button which opens the modal. Regards

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No
Tags