How to remove select2 from dom

jdennison picture jdennison · Oct 12, 2013 · Viewed 81k times · Source

Say we have a simple select2 list:

<select id="e1">
  <option value="AL">Alabama</option>
    ...
  <option value="WY">Wyoming</option>
</select>

Initiated like:

$("#e1").select2();

How can I remove select2 and return it to a regular dropdown? I can't find any examples or entry in documentation.

Something like:

$("#e1").select2('remove'); 

would be nice.

Answer

PSL picture PSL · Oct 12, 2013

You need to use destroy method on select2. See the Documentation

i.e

 $("#e1").select2('destroy');