# jQuery

Select2

Getting select2 values programmatically:

$(<span class="hljs-string">'#mySelect2'</span>).val(<span class="hljs-string">'1'</span>); <span class="hljs-comment">// Select the option with a value of '1'</span> $(<span class="hljs-string">'#mySelect2'</span>).trigger(<span class="hljs-string">'change'</span>); <span class="hljs-comment">// Notify any JS components that the value changed</span>

[https://select2.org/programmatic-control/add-select-clear-items](https://select2.org/programmatic-control/add-select-clear-items)