如果我的文本框中有文本,我想禁用下拉列表。文本框 ID 为“newAccessPoint”,下拉列表 ID 为“selectAccessPoint”
jQuery:
if ($.trim($('#newAccessPoint').val()).length() != 0) {
$('#selectAccessPoint').attr('disabled', 'disabled');
}
HTML 标记:
<table class="data-table">
<tr>
<td><label for ="AccessPoint" class="xl">Access Point:</label></td>
<td><%= Html.DropDownListFor(x => x.AccessPointsList.Id, Model.AccessPointsList.AccessPoints.OrderByDescending(x => x.Value.AsDecimal()), new { @id = "selectAccessPoint", @class = "info1"})%></td>
</tr>
<tr>
<td><label for ="AccessPoint" class="xl">Or Add New:</label></td>
<td><%= Html.TextBoxFor(x => x.AccessPointsList.AccessPoint, new { @id = "newAccessPoint", @class = "location info2 xl", maxlength = "250" }) %></td>
</tr>