Created
August 29, 2019 02:17
-
-
Save adamcrampton/e50d589d13db4a65393bd773dd58a64a to your computer and use it in GitHub Desktop.
Dynamically build jQuery select options
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
function buildOption(value, text, selected) { | |
return $("<option/>", { | |
value: value, | |
text: text, | |
selected: selected | |
}); | |
} | |
// Usage: | |
// $('#myselect').append(buildOption(key, value, selected)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment