Skip to content

Instantly share code, notes, and snippets.

@yohangdev
Created December 1, 2014 09:02
Show Gist options
  • Save yohangdev/f8ebf46c6e8c068c8306 to your computer and use it in GitHub Desktop.
Save yohangdev/f8ebf46c6e8c068c8306 to your computer and use it in GitHub Desktop.
What is the best way to add options to a select from an array
selectValues = { "1": "test 1", "2": "test 2" };
$.each(selectValues, function(key, value) {
$('#mySelect')
.append($('<option>', { value : key })
.text(value));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment