how to use Select2 in html




Select2 was designed to be a replacement for the standard box that is used by the browser. By default it supports all options and operations that are available in a standard select box, but with added flexibility.





example


<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>


<form action="">
<select class="js-example-basic-multiple" multiple="multiple">

<option value="AK">Alaska</option>
<option value="HI">Hawaii</option>

<option value="CA">California</option>
<option value="NV">Nevada</option>
<option value="OR">Oregon</option>
<option value="WA">Washington</option>

<option value="AZ">Arizona</option>
<option value="CO">Colorado</option>
<option value="ID">Idaho</option>
<option value="MT">Montana</option>
<option value="NE">Nebraska</option>
<option value="NM">New Mexico</option>
<option value="ND">North Dakota</option>
<option value="UT">Utah</option>
<option value="WY">Wyoming</option>

  </select>
</form>
 <script type="text/javascript">
  $(".js-example-basic-multiple").select2();
 </script>

No comments