【发布时间】:2017-10-31 22:56:08
【问题描述】:
我试图阻止用户使用 Javascript 输入文本区域。
为什么这不起作用?
$("textarea").on("input", function (e) {
console.log("returning"); //This prints
e.preventDefault();
return false;
//Even though this code runs when text is inputed into the textarea, it still doesn't prevent user input. Shouldn't returning false do that?
});
【问题讨论】:
-
试试
keydown而不是输入 -
输入事件在之后触发,有输入到控件。引用developer.mozilla.org/docs/Web/Events/input _ -- “当 、
标签: javascript jquery