gpt4 book ai didi

javascript - 输入框中的向上/向下箭头不执行任何操作

转载 作者:行者123 更新时间:2023-11-30 08:13:10 25 4
gpt4 key购买 nike

我怎样才能制作<input>元素没有反应按下 Up 箭头(keyCode 38)或 Down 箭头(keyCode 40),而它们是聚焦的?我在该项目中使用 jQuery,但如果更容易的话,我毫不犹豫地反对用原始 JS 编写它。

最佳答案

像这样:

$('.yourinputclass').keypress(function(e) {
if(e.which == 38 or e.which == 40) return false; // or you can use e.preventDefault(); like it was mentioned in the comments
});

文档 here

关于javascript - 输入框中的向上/向下箭头不执行任何操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7573948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com