我想禁用第一个元素“ Accreditation”,因为它只是一个标签,但是当它被选中时,我会遇到异常。为了避免这种情况,默认情况下应禁用它,然后选择下一个第一个元素
@Html.DropDownListFor(model => model.ReportTemplate.AccreditationId,
Model.lstAccrediation,
"Accreditation",
new { @class = "selectmenu", @id = "ddlAccreditationId",
data_val = "false" })
答案 0 :(得分:2)
这已解决了问题,并有助于完成要求
/* To Disable the first element in drop-down Accreditation */
$("#ddlAccreditationId option[value='0']").attr("disabled", true);