$(function() { var select = $('.selectedcity2'); select.html(select.find('option').sort(function(x, y) { return $(x).text() > $(y).text() ? 1 : -1; })); $('.selectedcity2').prepend('<option disabled selected>Select city</option>'); });
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter