Select2 has several built-in methods that allow programmatic control of the component.

Opening the dropdown

Methods handled directly by Select2 can be invoked by passing the name of the method to .select2(...).

The open method will cause the dropdown menu to open, displaying the selectable options:


Closing the dropdown

The close method will cause the dropdown menu to close, hiding the selectable options:


Checking if the plugin is initialized

To test whether Select2 has been initialized on a particular DOM element, you can check for the select2-hidden-accessible class:

if ($('#mySelect2').hasClass("select2-hidden-accessible")) {
    // Select2 has been initialized

See this Stack Overflow answer).

Destroying the Select2 control

The destroy method will remove the Select2 widget from the target element. It will revert back to a standard select control:


Event unbinding

When you destroy a Select2 control, Select2 will only unbind the events that were automatically bound by the plugin. Any events that you bind in your own code, including any Select2 events that you explicitly bind, will need to be unbound manually using the .off jQuery method:

// Set up a Select2 control

// Bind an event
$('#example').on('select2:select', function (e) { 
    console.log('select event');

// Destroy Select2

// Unbind the event