auto sorting disabled

 <!DOCTYPE html>

<html>

<head>
<title>Title of the document</title>
<link href=“https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/css/select2.css” rel=“stylesheet” />

<script src=“https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.js”></script>
<script src=“https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.js”></script>
</head>
<script>

$(document).ready(function () {

$(“select”).select2();

$(“select”).on(“select2:select”, function (evt) {
var element = evt.params.data.element;
var $element = $(element);

$element.detach();
$(this).append($element);
$(this).trigger(“change”);
});

$(‘.js-example-basic-multiple’).select2();
});

</script>

<body>
<form action=“” method=“get”>

<select style=max-width:910%; class=“js-example-basic-multiple” name=“states[]” multiple=“multiple”>
<option value=“AL”>Alabama</option>
<option value=“B”>BAT</option>
<option value=“C”>CAT</option>
<option value=“WY”>Wyoming</option>
</select>

<input type=“submit” value=“Submit”>

</form>
</body>

</html>

Leave a Comment

Your email address will not be published. Required fields are marked *