I have a select element that looks like this:
<select id="productId">
</select>
My current jquery is below:
...
if (data.success) {
var items = [];
$.each(data.products, function(key, val) {
items.push('<options id="' + val + '">' + key + '</option>');
});
var options = items.join('');
$("#productId").html(options);
//$("#productId").val(options);
//$("#productId").append(options);
}
None of my attempts will update the select tag with my new options. What am I missing?
try this: