jquery - 同一页面上的多个模式上的相同按键
问题描述
我为页面上的所有模式窗口使用相同的按键。但是当多个弹出窗口同时打开时。我在一个模式上移动键,但它也开始在其余模式窗口上工作
$(document).keydown(function(e) {
if ($tbody.find('.' + highlightClass).length) {
if (e.which != 40 && e.which != 38) {
return false;
}
if (e.which == 40) { //down arrow
gotoNext();
e.preventDefault();
} else if (e.which == 38) { //up arrow
gotoPrevious();
e.preventDefault();
}
}
});
解决方案
event.stopPropagation()
请在调用之前尝试使用gotoPrevious()
和gotoNext()
。我也会在打电话e.preventDefault()
之前尝试打电话gotoPrevious()
gotoNext()
推荐阅读
- c - 尝试查找复数的绝对值时输出错误,始终为 1
- python - 为任何 n 值扩展 (x+y)**n 二项式
- logstash - 如何在 Logstash 中将 JSON 对象转换为 STRING?
- .net - Blazor 中的 RazorComponent 多次包含在同一页面共享代码中
- c# - 在 VS10 .NET 表单中获取自定义控件的 IDesignerHost 时出现问题
- reactjs - 在 React 应用程序上运行到“npm-start”时出错
- unity3d - Unity animator 使物体反向重力
- c++ - 如何修复 IBPP::LogicException:未知或不支持的语句类型?
- android - 我想删除 Android Studio 中视图的约束?
- mongoose - mongoose array push 没有保存我的条目,也违背了我使用 push 的简单愿望