我正在使用 MVC3 Razor。我想在 @Html.TextboxFor 的 onchange 事件上更改标签的文本。
这是我正在尝试的代码:
在 View 中:
@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @onchange = "event();" })
JavaScript:
function event() {
document.getElementById('lblSelectedProductName').value ="sam";
}
但它不起作用。
最佳答案
使用这个 jquery 语法它工作正常。
@Html.TextBoxFor(x => x.ItnScanCaseCode, new { @id="txtid",@onchange = "onchangeevent();" })
function onchangeevent(){
$('#txtid').val('sam');
}
关于javascript - 在 mvc3 中更改 @Html.TextboxFor 的 onchange 事件的标签文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17874849/