给Select赋值 innerHTML 不兼容IE6\IE7\IE8\IE9
<select class="b-select" id="location-province" name="Province" default="@Model.Province">XXXXXX</select>
//根据条件,查到对应的省或市或区下拉框选项
function LoadListProvinceData(parentId, objTarget) {
if (ListProvinceData == null) {
LoadDivisionsList();
}
var html = defaultOption;
if (ListProvinceData != null) {
$.each(ListProvinceData, function (index, item) {
if (parentId == item.ParentId) {
html += '<option id="' + item.Id + '" value="' + item.Id + '">' + item.NodeName + '</option>';
}
});
}
//objTarget.html(html);
document.getElementById(objTarget).innerHTML = html;
}
给XXX赋值用下面的方法不兼容IE6\IE7\IE8\IE9
document.getElementById(objTarget).innerHTML = html;
更改为下面的赋值方法
//根据条件,查到对应的省或市或区下拉框选项
function LoadListProvinceData(parentId, objTarget) {
if (ListProvinceData == null) {
LoadDivisionsList();
}
document.getElementById(objTarget).length = 0;
document.getElementById(objTarget).options.add(new Option("请选择", ""));
if (ListProvinceData != null) {
$.each(ListProvinceData, function (index, item) {
if (parentId == item.ParentId) {
document.getElementById(objTarget).options.add(new Option(item.NodeName, item.Id));
}
});
}
}