Topic: Selected option of material select jquery

Sara Rodríguez free asked 5 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('', function (e) { $('#prueba').val("1"); }); What I'm doing wrong? Thanks

Sara Rodríguez free commented 5 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 5 years ago

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

Please insert min. 20 characters.


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



Specification of the issue

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