0
在剃刀视图中,我使用Html.EditFor。脚本剪切最后字符
@Html.EditorFor(model => model.Salary, new { htmlAttributes = new { id = "SalaryEdit", @class = "form-control", onkeypress = "myFunction()" } })
脚本
function myFunction() {
var source = $('#SalaryEdit');
console.log($("input[id^='SalaryEdit']").val());
}
当我在EditorFor例如键入:1,23。它只显示我1,2。它总是削减最后的字符。是什么原因?
使用'onkeyup'而不是'onkeypress'为'keypress'事件表示一个字符__being__类型。另外,当你使用jQuery时,使用unobstrusive事件处理程序 – Satpal