I want to change materialize select box value by jquery.
I am using $('#myselect').val('1');
on onchange
event of other select box but it not works.
$("#select1").change(function() {
$('#myselect').val('1');
});
I want to change materialize select box value by jquery.
I am using $('#myselect').val('1');
on onchange
event of other select box but it not works.
$("#select1").change(function() {
$('#myselect').val('1');
});
The new method is formSelect(), use this after you have updated the select.
Rather than using .val(), it's cleaner to set value as usual with jQuery :
Using delegated event fixes the problem for me.
HTML
JS
I found proper solution from here
For multiple in materialize
And now you just little change in your Javascript section and that is the url:
instead of
or any other link of materialize.min.js
And for multiple select enabling :
Thats it. You can check demo of this solution : JSFiddle
This is similar to what logikal answered but I think is cleaner:
It appears to work fine for me, changing the first drop down, resets the value of the second drop down to 1.
I have done a rough implementation on jsFiddle: http://jsfiddle.net/55r8fgxy/1/
JS: