Change value of materialize select box by jquery

前端 未结 11 1631
滥情空心
滥情空心 2020-12-29 22:18

I want to change materialize select box value by jquery.

I am using $(\'#myselect\').val(\'1\'); on onchange event of other select box but

11条回答
  •  余生分开走
    2020-12-29 22:51

    This answer might be late but it might help someone else.

    On Ready add the line below

    $(document).ready(function () {
            $('select').formSelect();
        });
    

    Each time you change an option within your Select add the line below

    $("#select1").change(function() {
        $('#myselect').val('1');
        $('select').formSelect();
    });
    

    This is what worked for me, hope it helps.

提交回复
热议问题