Jquery Select2 Set Value

jquery select2 set value
<select id="lang" >
<option value="1">php</option>
<option value="2">asp</option>
<option value="3">java</option>

select2 tags set value jquery
data: ['one','two'],
tags: true
get select2 selected value jquery
$('#id :selected').text();
select2 replace options
var options = [];
$.each(dataReturn, function (i, obj) {
text: obj.NickName,
id: obj.NickName
data: options
select2 dropdown with option to add new item
.on('select2:open', () => {
$(".select2-results:not(:has(a))").append('<a href="#" style="padding: 6px;height: 20px;display: inline-table;">Create new item</a>');

Leave a Comment