Created
April 15, 2017 04:34
-
-
Save ansidev/1c2d1693f086e82cec5cf6bd075e3454 to your computer and use it in GitHub Desktop.
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
// JQuery tips for select | |
var selectElement = $('#select-id'); | |
// Clear all select options | |
selectElement.empty(); | |
// Append options to select | |
selectElement.append($('<option>', { | |
value: 'value', | |
text: 'text' | |
})); | |
// Append options from a collection of items | |
$.each(items, function (i, item) { | |
selectElement.append($('<option>', { | |
value: item.value, | |
text : item.text | |
})); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment