jQuery

 

Select2

Getting select2 values programmatically:

$('#mySelect2').val('1'); // Select the option with a value of '1' $('#mySelect2').trigger('change'); // Notify any JS components that the value changed

https://select2.org/programmatic-control/add-select-clear-items

 


Revision #1
Created 2026-03-04 09:51:46 UTC by Diogo Gonçalo Lourenço
Updated 2026-03-04 09:51:46 UTC by Diogo Gonçalo Lourenço