Skip to main content
3 of 3
Active reading. [<http://english.stackexchange.com/questions/4645/is-it-ever-correct-to-have-a-space-before-a-question-or-exclamation-mark#comment206109_4645>]
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

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('')); 
Dr Fred
  • 989
  • 9
  • 15