Created
December 1, 2014 09:02
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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