Topic: MaterialSelect Selecting an Option.

Thomas Emmanuel free asked 4 years ago

Expected behavior

Update the selected option dynamically.

Actual behavior

    <select id="country" class="mdb-select">
        <option value="" disabled selected>Select</option>
        <option value="ind">India</option>
        <option value="usa">America</option>
        <option value="myr">Malaysia</option>

By Default "Select" is selected.In my application there is customer search field, if the customer is from Malaysia, i have to update the country dropdown with the customer's country.

Before updating to 4.8.10 i was using 4.7.7


This was working fine.

But after 4.8.10. this doesn't work anymore. any alternative method to select an option?


poomkawin free answered 4 years ago


$('#country option[value="myr"]').attr('selected', true);
should solve your issue.

Here's an example:

Thomas Emmanuel free commented 4 years ago

Thanks mate :) worked perfect!

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: 4.8.10
  • Device: Lenovo, Mac
  • Browser: Chrome, Firefox
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No