What\'s the easiest way to add an option to a dropdown using jQuery?
option
Will this work?
$(\"#mySelect\").append(\'My
Personally, I prefer this syntax for appending options:
$('#mySelect').append($('', { value: 1, text: 'My option' }));
If you're adding options from a collection of items, you can do the following:
$.each(items, function (i, item) { $('#mySelect').append($('', { value: item.value, text : item.text })); });