select2 dropdown with option to add new item

Remove the selected options : 
-----------------------------
$('#mySelect2').val(null).trigger('change');

============================================

Completly remove the select2 initialization :
--------------------------------------------
$('#payment_method').html('').select2({data: [{id: '', text: ''}]});

4
1
Harry Maik 90 points

                                    $('#select2')
    .select2()
    .on('select2:open', () => {
        $(".select2-results:not(:has(a))").append('<a href="#" style="padding: 6px;height: 20px;display: inline-table;">Create new item</a>');
})

4 (1 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
select2 clear the select select 2 clear all select 2 clear how add select2 dropdown dynamically select2 clear search fiedl after select select2 clear options allowclear select2 add option to dropwdown list select2 trigger new option on clear clear select2 selected value clear select2 and fill select clear options select2 clear options ajax select2 dropdown add span in select select2 dropdown add option dynamically select2-selection__clear event how to clear all selected value in select2 clear button select2 add select option dropdown in select2 clear all options select 2 how to clear selected option in select2 select2 clear selected option how to clear select2 selected items how to clear select2 data select2 clearable append to a dropdown select2 append option select2 select2 add option html select2 trigger clear select2 select clear select2{'clear'} clear select2 not clear value clear true in select2 select2 add option and set selected clear value select2 how to add select2 to dropdown clear select2 every call select2 how to clear selection add value in select2 dropdown select2 multiple select clear clear selected select2 select2 Add, select, or clear items reset a select2 select 2 how to add new option select2 dropdown clear selection select2 destroy and clear reset all select2 select2 event clear how to remove allow clear in select2 clear select2 selection select 2 clear all options select2 allow clear add button to select2 dropdown add clear button select2 clear selected option select2 clear select2 use js select2 append option append to dropdownParent in select2 select2-selection__clear hide select2-results__option clear select2 clear search dropdown clear select2.result.option select2 clear search input select2 get value before clear get value 'select2:clearing select2 clear selected item select2 on clear event select2 option allow clear how to add new in select2 option clear value in select2 clear select 2 select2 clear method on select2 clear items event clear select2 dropdown clear select2 list select2 add button to dropdown select2 clearing options not working clear all options select2 reset selected select2 select2 with clear button reset select2 options select2 add html to option select2 reset selected select2 clear button reset select2 multi select dropdown search with dynamically add options all select2 selected value clear select2 reset option how to clear select2 how to append select2 to existing dropdown clear selected value in select2 clear selected value select2 select2 clear select value select2 clear all option selected select2 clear all selected how to clear select2 picker clear manually javascript clear select2 select 2 clear options select2 add option to list select2 reset all select2 clear selections select2 clear. select2 clear all data select2 clear all items how to trigger select2 clear Select2 add option and select select2 multiple clear all trigger unselecting select2 to clear option on clear select2 how to clear select2 value clear val select2 select2 dropdown add button jqeury ajax select2 manual select2.val select2 jquery ajax append option set value select2 select 2 selected value jquery select option in select2 how to clear data in select2 select2 find option and trigger select a option in select 2 select2 add option selected how to set an element up the select2 select2:select javascript select2 select based on value how to remove data to select2 in javascript how to make select2 empty selectable select2 remove all options select2 multiselect on clear select2 clear selected select2 data selected jquery selected option select2 select2 add selected value SELEct 2 add selected value clear selectio value in jquery select2 select2 selected jquery select option change select 2 set select2 value add item in select 2 js select2 jquery add option select2 add option ajax set value select 2 select 2 jquery add select2 select option programmatically append select 2 dropdown bootstrap select2 clear selection remove a option from select 2 using jquery how to clear data from select2 dropdown select2 clear option select2 edit selected value select2 select option select2 js set selected select2 option selected how to clear select2 selected value in js change select 2 manually select2 set selection select2 reset options jquery select2 reset selection select 2 resset select2 change selected option select2 set id select2 dropdown selected add remove options + select2 select2 reset data select2 dom clear select2 slecteed value select 2 select a value add select2 to input select2 reset value jquery add item in select2 js inti value of select2 jquery set options to select 2 select2 value clear select2 selected value clear select value in select2 jquery select2 reset selected value select 2 dropdown add item add value in select 2 select2 jquery set value select2 on clear append option 0 select2 multiple update new options select2 add remove option dynamically select2 on clear select2 options select on update select2 add manually how to populate a select2 input using jquery set value on select 2 select2 allow clear one option clear select2 value select2 clear ajax select2 value change empty selection on change select2 clear select2 value in jquery select2 set option value .val select2 select 2 not clearing selected value select2 select option using jquery SELECT2 ADDABLE DROPDOWN select2 on select option select2 set by value select2 clear values jquery select2 set value jquery select2 set valuej select2 dropdown items with bigger then selected select2 set value jquery fill values in select2 one by one .val in select2 fill values in select2 select option in select2 jquery select2 clear item select2 insert at first select2 reset selection select2 clear select2 Clear select select2 empty selection select option select2 by value select 2 update select2.js clear select2 clearn option select2 add new option if not found select2 selected option jquery select2 select option by value programmatically select2 selected value select2 4 update dropdown list select2 add option dynamically select2 new option clear selected value in select2 js select2 update selected value select2 clear all options Select2 Force Select select2 add new option select2 reset option select select 2 select values programaticalliy select2 change selected value select2 set value change select2 add value add data value to select2 options select2 reset value select 2 selected value selecting a select2 option jquery how to make a select2 to add value out of options bootstrap select2 change option data select2 on reset select2 reset dunamic options select 2 reset dunamic options select2 how to know if programmatically select select2 programmatically select event select 2 set selected option select 2 option selected in jquery select2 set selected value select 2 set value select2 append new option select2 add new option ajax SELECT2 apend data event select2 add item to end select2 update options select2 update value select2 val set selected item in select2 how to select option in select2 in jquery select option in select2 using jquery select2 set selected trigger clear select2 select2 clear input select2 jquery append reset all select2 options how to select value in select2 jquery select2('data') set value select2 update select2 manually select select2 append option ajax select2 append option jquery select2 dropdown with option to add new item select2 select option by value how to clear select2 dropdown in jquery select2 selecting a select2 option select2 option reset adding or removing options to select 2 jquery js select2 clear list clear all selected options select2 clear select2 selected option clear select2 options select2 manually set value select2 add options select2 clear value select2 seelect without append select 2 select value js select2 add option select2 set value select2.js clear selection select2.js select nothing select2 select valus select2 reset select2 select using jquery select2 adding another id to select select2 add option clear select2 jquery jquery clear select2 js select2 preselect object jquery select2 add remove row bootstrap select2 add options clear selection select2 clear select2 selected value jquery select2 change valyue select2 value select2 select by value select 2 select item using jquery select2 optin selected clear select2 select2 clear selected value select2 multiple manual select select2 selected change button for select2 clear select 2 dropdown val select2 select value set select2('data') select2 set datasource programmatically select2 clear selection select 2 clear and set datasource select 2 set data select2 change value add option to multiple select2 select2 empty select 2 select by value clear select 2 option javascript select2 trigger ajax manually javascript select2 manual select 2 selected jquery select2 manually aselct select2 clear default add option to select2 jquery update select2 value jquery select2 set select2 value selected jquery change select2 option jquery select2 select value javascript jquery select2 set selected jquery select2 selected value set select2 value jquery jquery select2 clear cache change select2 value jquery insert values to select2 multiple js select2 reset value without append add val select2 jquery jsfields how to clear select2 option in jquery empty select2 jquery select select2 option jquery set selected option jquery select2 jquery select2 array update how to set value in select2 using jquery set value in select2 jquery select2 select value using jquery select2 ajax clear data fill select2 jquery select2 clear options
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source