What\'s the easiest way to add an option to a dropdown using jQuery?
option
Will this work?
$(\"#mySelect\").append(\'My
You can try this-
$('#selectID').append($('', { value: value_variable, text : text_variable }));
Like this-
for (i = 0; i < 10; i++) { $('#mySelect').append($('', { value: i, text : "Option "+i })); }
Or try this-
$('#selectID').append( ''+text_variable+'' );
for (i = 0; i < 10; i++) { $('#mySelect').append( ''+'Option '+i+'' ); }