I use this jquery function to populate a dropdown box. Works great, but I want to add an option:
<option value="">select</option>
the first option! How is this to be done?
function populate_cantons() {
$.getJSON('http://domain.com/v3/ajax/fetch_canton.php', {country:$('#country').val()}, function(data) {
var select = $('#cantons');
var options = select.prop('options');
$('option', select).remove();
$.each(data, function(index, array) {
options[options.length] = new Option(array['canton']);
});
});
}