我正在尝试更改下拉菜单的标题。我正在使用此Multi-select plugin。
但是我无法通过JavaScript动态更改下拉菜单的文本(下拉标题)。
$('#pickere-buttonTitle').multiselect({
buttonText: function(options, select) {
return dist;
}
});
方法2
$('#pickere option:selected').value = state;
HTML代码
<div class="form-group">
<label>Select District:</label>
<select class="form-control" id="district-pickere">
</select>
</div>
<div class="form-group">
<label>Select Sub District:</label>
<select class="form-control" id="subdistrict-pickere">
</select>
</div>
JS代码
function editUser(id, name, mob, mail, addr, state, dist, subdist, type, role) {
console.log("USER DATA > > " + name + " > > " + mob + " > > " + mail + " > > " + addr);
console.log("USER LOC > > " + state + " > > " + dist + " > > " + subdist );
document.getElementById("namee").value = name;
document.getElementById("mobilee").value = mob;
document.getElementById("emaile").value = mail;
document.getElementById("addre").value = addr;
$('#state-pickere option:selected').value = state;
$('#district-pickere-buttonTitle').multiselect({
buttonText: function(options, select) {
return dist;
}
});
$('#sub-district-pickere-buttonText').value = subdist;
}
更新
$('#district-pickere').multiselect({
includeSelectAllOption: true,
enableFiltering: false,
maxHeight: 300,
nonSelectedText: dist
});
以上代码在初始化期间有效。但是,当单击按钮时,如何从另一个功能更改未选择的测试?