我想在我的選擇下拉菜單中添加一個選項。我無法做到這一點。任何人都可以提供任何解釋或正確的代碼技術來做到這一點?下面是我的代碼。如何從jquery添加選項
$.ajax({
async: false,
url: '/api/TaskApi/' + "0",
type: 'GET',
success: function (data) { //data is an array of objects
$.each(data,function(i,data){//data is object
var d = data.id;
var u = data.user_Name;
console.log(d, u);
$('#example-getting-started').append($('<option value = "'+ d+'">'+ u +'</option>'));
});
},
failure: function() {
alert("Failed to load Users");
}
});
<div class="col-lg-12 spacing">
<div class="col-lg-6">
<label>Assigned To</label>
</div>
<div class="col-lg-6">
<div class="dropdown">
<select id="example-getting-started" multiple="multiple">
<option value="cheese">Cheese</option>
</select>
</div>
</div>
</div>
https://github.com/davidstutz/bootstrap-multiselect
它沒有傷心地工作:( –