Last active
February 13, 2019 07:24
-
-
Save melvinstanly/0c556ebcbb93071bcbc6fd675ee59f42 to your computer and use it in GitHub Desktop.
jQuery select2
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
/* Dynamically add options to select field */ | |
// Assuming 'custom-select' is the class of select field | |
<select class="custom-select"> | |
<option value="a">A</option> | |
<option value="b">B</option> | |
<option value="c">C</option> | |
</select> | |
var mySelect = $(".custom-select").append('<option value="test">Test</option>'); | |
mySelect.trigger("change"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment