95
rated 0 times
[
98]
[
3]
/ answers: 1 / hits: 42001
/ 9 Years ago, fri, february 27, 2015, 12:00:00
I want to sort the select2 options in alphabetical order. I have the following code and would like to know, how can this be achieved:
<select name=list id=mylist style=width:140px;>
<option>United States</option>
<option>Austria</option>
<option>Alabama</option>
<option>Jamaica</option>
<option>Taiwan</option>
<option>canada</option>
<option>palau</option>
<option>Wyoming</option>
</select>
$('#mylist').select2({
sortResults: function(results) { return results.sort(); }
});
I want to sort the data via 'text'.
More From » jquery