javascript - 通过脚本 jquery 将事件类型 (keyup) 更改为 (keyup.enter)
问题描述
我需要创建一个 jQuery 脚本来忽略 keyup 或 keypress 事件侦听器函数的执行,并在我按下键盘上的 Enter 键时执行它。
我正在使用 jquery 的一个组件,所以我无法更改输入的 html 代码。
HTML
<input type="text" id="search" class="search" (keyup)="searchDataTable($event)">
查询:
$(document).on("keypress", "input", function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode != 13) {
console.log('it is not enter keyCode ')
//stop the execution of methode affected by event
}
});
我正在寻找禁用侦听器的 javascript 方法。 我想要:
A.仅当我按下“回车”时才执行函数。searchDataTable($event)
-或者-
B.通过其他脚本 jquery 将事件类型 (keyup) 更改为 (keyup.enter)。
解决方案
推荐阅读
- matlab - 梯度下降的实现(Matlab)
- c++ - 安全警报和脚本错误的问题
- r - R参考(文档,规范)
- javascript - 如何使用按钮触发编辑结束?
- maven - 在 JFrog Artifactory URL 中指定用户名和密码以避免提示输入凭据
- javascript - 如何防止抓取应用程序从浏览器下载和检测 mp3 文件
- java - Android导航组件不断重新加载WebView
- regex - 正则表达式适用于 regex101 而不是 Splunk
- python - 将 stats.percentileofscore 逐列应用于每一行
- jquery - 对话框不是对话框中的函数对话框