--- layout: default title: Examples - Select2 slug: examples ---
Select2 can take a regular select box like this...
and turn it into this...
Select2 also supports multi-value select boxes. The select below is declared with the multiple
attribute.
A placeholder value can be defined and will be displayed until a selection is made.
This works for multiple select boxes as well.
Select2 provides a way to load the data from a local array.
You can provide initial selections with array data by providing the option tag for the selected values, similar to how it would be done for a standard select.
Select2 comes with AJAX support built in, using jQuery's AJAX methods.
Select2 will pass any options in the ajax
object to
jQuery's $.ajax
function.
Select2 will correctly handled disabled results, both with data coming
from a standard select (when the disabled
attribute is set)
and from remote sources, where the object has
disabled: true
set.
Unlike other dropdowns on this page, this one matches options only if the term appears in the beginning of the string as opposed to anywhere:
This custom matcher uses a compatibility module that is only bundled in the full version of Select2. You also have the option of using a more complex matcher.
Select2's default matcher will ignore diacritics, making it easier for users to filter results in international selects. Type "aero" into the select below.
Select2 supports displaying the messages in different languages, as well as provding your own custom messages that can be displayed.
The language does not have to be defined when Select2 is being
initialized, but instead can be defined in the [lang]
attribute of any parent elements as [lang="es"]
.