Changing selection in a select with the Chosen plugin

后端 未结 4 1808
时光说笑
时光说笑 2020-12-08 01:42

I\'m trying to change the currently selected option in a select with the Chosen plugin.

The documentation covers updating the list, and triggering an event when an o

4条回答
  •  一整个雨季
    2020-12-08 02:26

    My answer is late, but i want to add some information that is missed in all above answers.

    1) If you want to select single value in chosen select.

    $('#select-id').val("22").trigger('chosen:updated');
    

    2) If you are using multiple chosen select, then may you need to set multiple values at single time.

    $('#documents').val(["22", "25", "27"]).trigger('chosen:updated');
    

    Information gathered from following links:
    1) Chosen Docs
    2) Chosen Github Discussion

提交回复
热议问题