I cannot seem to find it. Thanks!
Example:
$("#MySelect").append(new Option("MyOption", "MyOption", true, true));
The Mozilla Dev Center is the de facto standard documentation site for all things JavaScript.
option element reference:<option> elementHTMLOptionElement interface (which is implemented by the above)HTMLOptionElement interface specSince you're using jQuery, however, there's a better way to construct elements.
$('#MySelect').append('<option></option>',
{
text: 'MyOption',
value: 'MyOption',
selected: true
})
I'm not sure what the last true argument should do - at least in Chrome, new Option('text', 'value', true, true) seems to return the same thing as new Option('text', 'value', true).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With