Using the $.map() function, you can do this in a more elegant way:
$('#mySelect').html( $.map(selectValues, function(val, key){ return '<option value="' + val + '">'+ key + '</option>'; }).join('')); Using the $.map() function, you can do this in a more elegant way:
$('#mySelect').html( $.map(selectValues, function(val, key){ return '<option value="' + val + '">'+ key + '</option>'; }).join(''));