How to set selected value of jquery select2?

后端 未结 28 1351
野趣味
野趣味 2020-11-30 00:00

This belong to codes prior to select2 version 4

I have a simple code of select2 that get data from ajax



        
28条回答
  •  渐次进展
    2020-11-30 00:43

        $("#select_location_id").val(value);
        $("#select_location_id").select2().trigger('change');
    

    I solved my problem with this simple code. Where #select_location_id is an ID of select box and value is value of an option listed in select2 box.

提交回复
热议问题