在表格中把tab换成enter键------ivx


为了方便用户输入,把tab键替换成enter回车
方法如下:
添加一个fx函数
`document.addEventListener(‘keydown’, function(event) {
if (event.key === ‘Enter’ && !event.shiftKey) {
event.preventDefault();
var focusableElements = document.querySelectorAll(‘input, button, select, textarea, a[href], area[href], [tabindex]:not([tabindex=“-1”])’);
var focusedIndex = Array.prototype.indexOf.call(focusableElements, document.activeElement);
if (focusedIndex >= 0 && focusedIndex< focusableElements.length - 1) {
focusableElements[focusedIndex + 1].focus();
} else {
focusableElements[0].focus();
}
}
});

console.log(“enter”)
`
然后再页面加载的时候,运行他。他的只要作用就是添加一个时间监听器。然后按下回车的时候直接跳向下一个框框。
如果还有不明白的可以参考我的案例。
VxEditor

相关推荐

  1. golang实现pdf自动行的表格

    2024-07-12 08:00:04       62 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-12 08:00:04       70 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-12 08:00:04       74 阅读
  3. 在Django里面运行非项目文件

    2024-07-12 08:00:04       62 阅读
  4. Python语言-面向对象

    2024-07-12 08:00:04       72 阅读

热门阅读

  1. 基于K线图的股市情绪分析及预测模型构建

    2024-07-12 08:00:04       33 阅读
  2. Android Retrofit post请求,@Body传递的参数转义问题

    2024-07-12 08:00:04       29 阅读
  3. Spring MVC 全面指南:从入门到精通的详细解析

    2024-07-12 08:00:04       29 阅读
  4. 每日一道算法题 204. 计数质数

    2024-07-12 08:00:04       29 阅读
  5. 初识c++

    初识c++

    2024-07-12 08:00:04      25 阅读
  6. HTTP有哪些失败原因?怎么处理?

    2024-07-12 08:00:04       35 阅读
  7. 小白学webgl合集-import.meta.url 和 new URL() bug

    2024-07-12 08:00:04       33 阅读
  8. Excel中用VBA实现Outlook发送当前工作簿

    2024-07-12 08:00:04       31 阅读
  9. Openresty+lua 定时函数 ngx.timer.every

    2024-07-12 08:00:04       23 阅读
  10. 1.Introduction to Spring Web MVC framework

    2024-07-12 08:00:04       29 阅读
  11. 【layui表单赋值为空问题查找】

    2024-07-12 08:00:04       26 阅读
  12. 云原生(Cloud native)

    2024-07-12 08:00:04       24 阅读