var o = new Option("option text", "value");/// jquerify the DOM object 'o' so we can use the html method$(o).html("option text");$("#selectList").append(o);
var html = '';
for (var i = 0, len = data.length; i < len; ++i) {html.join('<option value="' + data[i]['value'] + '">' + data[i]['label'] + '</option>');}
$('#select').append(html);
$.each(items, function (i, item) {// IMPORTANT: no selectors inside the loop (for the best performance)str += "<option value='" + item.value + "'> " + item.text + "</option>";});// you built a big string
$mySelect.html(str); // <-- here you add the big string with a lot of options into the selector.$mySelect.multiSelect('refresh');
甚至更快
var str = "";for(var i; i = 0; i < arr.length; i++){str += "<option value='" + item[i].value + "'> " + item[i].text + "</option>";}$mySelect.html(str);$mySelect.multiSelect('refresh');
let cities = {'ny':'New York','ld':'London','db':'Dubai','pk':'Beijing','tk':'Tokyo','nd':'New Delhi'};
for(let c in cities){$('#selectCity').append($('<option>',{value: c,text: cities[c]}))}