我在 ym asp.net mvc Web 应用程序中有以下 html:-
<span class="f">Customer Name</span>
<select data-val="true" data-val-length="The field CustomerName must be a string with a maximum length of 50." data-val-length-max="50" data-val-required="The CustomerName field is required." id="FirewallCustomer_CustomerName" name="FirewallCustomer.CustomerName"><option value="">Choose...</option>
//code goes here…
</select>
<span class="field-validation-valid" data-valmsg-for="FirewallCustomer.CustomerName" data-valmsg-replace="true"></span>
</div>
<div>
<span class="f">VLANS</span>
<select data-val="true" data-val-number="The field CustomerVLANSID must be a number." data-val-required="The CustomerVLANSID field is required." id="FirewallCustomer_CustomerVLANSID" name="FirewallCustomer.CustomerVLANSID"><option value="">Choose..</option>
</select>
<span class="field-validation-valid" data-valmsg-for="FirewallCustomer.CustomerVLANSID" data-valmsg-replace="true"></span>
<div>
<span class="f">VLAN IP</span> <input disabled="disabled" id="VLANIP" name="VLANIP" type="text" value="" />
</div>
<div><span class="f">VLAN Sub NET Mask</span> <input disabled="disabled" id="Subnetmask" name="Subnetmask" type="text" value="" />
</div>
</div>
我有以下脚本
$(document).ready(function () {
$("#FirewallCustomer_CustomerVLANSID").attr("disabled", "disabled");
$("#FirewallCustomer_CustomerName").change(function () {
var idDC = $(this).val();
var select = $("#FirewallCustomer_CustomerVLANSID");
$("VLANIP").val('');
$("Subnetmask").val('');
select.empty();
$("#SFirewallCustomer_CustomerVLANSID").removeAttr("disabled");
$.getJSON("/Firewall/LoadVLANSByCustomerName", { customername: idDC },
function (VLANData) {
select.append($('<option/>', {
value: null
}));
$.each(VLANData, function (index, itemData) {
select.append($('<option/>', {
value: itemData.Value,
text: itemData.Text
}));
});
});
});
});
但我面临以下问题:-
下拉列表将不会重新启用
$("#SFirewallCustomer_CustomerVLANSID").removeAttr("disabled");
和
$("VLANIP").val('');
$("子网掩码").val('');
不会清除文本。
任何人都可以建议有什么问题吗?谢谢