Material select selecting option

Topic: Material select selecting option

Jorge Nuñez Malledo asked 3 years ago


I'm having trouble using jquery code to select material select options. Finally got some time to isolate the problem

Having the snipped below, I have three questions

1. Why the selected option is not displayed?

2. Why option[value="2"] is not selected after this simple code?

$('#selectValue2-button').click(function() {

$('#select4-select option:selected').prop('selected', false); // clear previously selected value

$('#select4-select option[value="2"]').prop('selected', true); // Select value = 2

console.log('Selected value: ' + $('#select4-select').val()); // Check that value 2 is actually selected

$('.mdb-select').materialSelect({ destroy: true });



3. Why this is working properly in version 4.8.2?

Expected behavior

'Select...' option selected

'Option 2' selected after pressing of button

Actual behavior

No option selected before button click

No option selected after button click


Sebastian Kaczmarek staff pro premium commented 3 years ago

It seems like there's a problem with a label. Once I've removed it, the select control works as expected. It's definitely a bug we need to fix. Sorry for the inconveniences. See my snippet:

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: Thinkpad T480
  • Browser: Mozilla Firefox
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: Yes