Created
July 26, 2013 10:09
-
-
Save nmoliveira/6087782 to your computer and use it in GitHub Desktop.
Adding options to an html select using Jquery
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
// array with values to be added | |
selectValues = { "1": "test 1", "2": "test 2" }; | |
// for each value in the array append option to select | |
$.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