How to add Select2 on Dynamic element – jQuery

Select2 jQuery plugin is easy to add on the <select > element. Need to call the select2() method on the selector to initialize.

If you adding select2 on a class or select element and when you add an element dynamically then select2 is not initialized on that element.

In this tutorial, I show how you can initialize select2 on dynamically created HTML <select > element using jQuery.

I am loading select2 data using jQuery AJAX in the example.

How to add select2 on Dynamic element - jQuery

Read more

Loading data remotely in Select2 – Laravel 7

Select2 is a jQuery plugin which customize <select > element and adds multiple functionality like – searching, multiple option selections, etc.

You can import data using jQuery AJAX or directly list data in the element.

In this tutorial, I show how you can add select2 on a select element and load data using jQuery AJAX in the Laravel 7 project.

Loading data remotely in Select2 – Laravel 7

Read more

Change Selected option in Select2 Dropdown with jQuery

Select2 is a jQuery plugin that customizes HTML select element and makes it more user-friendly.

It adds search features and allows to add an image with options.

The HTML select element option can easily set selected using jQuery – $(selector).val(option-value);.

But this does not directly work with the Select2 dropdown element.

In this tutorial, I show how you can dynamically set an option selected in Select2 with jQuery.

Change Selected option in Select2 Dropdown with jQuery

Read more