I have a <select> element which has some initial values, how can I add a value to the select and then order it alphabetically.
I can add options with some simple JavaScript:
var select = document.getElementById("example-select");
select.options[select.options.length] = new Option('Text 1', 'Value1');
…but that only appends it to the end.
How can I sort a <select> element by JavaScript without using jQuery.
give this a try.