我很喜歡這個, 在Html.TextBoxFor值上進行操作時,我想更改另一個Html.TextBoxFor的只讀屬性。 我嘗試了幾種方法 - 使用IE它不起作用。 這裏的一些代碼:更新Html.TextBoxFor「只讀」屬性打開和關閉
@Html.TextBoxFor(x => x.NumberOfQuestion, new { id = "ExamOptions", onchange = "javascript:ReadOnlyHandle();" })
<script>
function ReadOnlyHandle() {
//document.getElementById("NoDiffNum").readOnly = true;
var startHSelect = document.getElementById("NoDiffNum");
debugger;
startHSelect.setAttribute("readonly", "true");
}
debugger;
</script>
,並在表中的行,我想改變:
<td id="NoDiffNum">@Html.TextBoxFor(model => model.Topics[i].NumberOfNoDifficulltySet)</td>
只讀屬性沒有改變 - 任何幫助是最歡迎!
您是否使用jQuery,如標籤所示? – Ted
您是否嘗試在輸入上設置只讀屬性,而不是在TD上設置? –
我確實使用JQuery –