如何 Onload() 将焦点设置为 jQuery Handsontable
How to Onload() set focus to jQuery Handsontable
在
jQuery Handsontable中将焦点加载设置为第一个字段的正确方法是什么?
这是示例链接 http://jsfiddle.net/4kvMq/4/
$(function () {
$(window).load(function () {
$('#example10grid table tbody tr td:first-child').focus();
});
});
甚至尝试手动设置焦点,但没有运气!
$('#btnGo').click(function() {
$(".dataTable table tbody tr td:first-child").focus();
});
非常感谢!
感谢您的请求。现在有一种公共方法可以做到这一点。
在按钮上使用它:
$('#btnGo').click(function(event) {
setTimeout(function() {
//timeout is needed because Handsontable normally deselects
//current cell when you click outside the table
$("#example10grid").handsontable("selectCell", 0, 0);
}, 10);
});
或者 DOM 就绪:
$(function() {
setTimeout(function() {
//timeout is needed because Handsontable normally deselects
//current cell when you click outside the table
$("#example10grid").handsontable("selectCell", 0, 0);
}, 10);
});
现场示例:http://jsfiddle.net/warpech/4kvMq/35/
你不能这样做。问题在于可动手处理焦点事件的方式。它将单击处理程序绑定到 hmtl
元素,并每毫秒检测一次光标是否在表上。因此,不能通过特定元素上的click()
或focus()
来更改焦点。
此外,由于出于安全原因,您无法使用 JavaScript 更改光标位置(并且 jQuery 无法在本地触发单击或焦点事件),因此您无法轻松更改单元格上的焦点。只能修改可动手表本身以更改选定的表格单元格。
相关文章:
- 需要垫片设置-jquery.flot/jquery.flot.selection
- 是否可以在调用时动态设置Jquery Accordion的活动面板
- 无法在其他调用上设置jQuery对话框选项
- 如何在jquery ajax响应后设置jquery滑块的起始值
- 如何设置jQuery微调器的最大值和最小值
- 设置jquery按钮,而不是php错误和成功状态
- 设置jquery对话框的高度
- 如何动态设置jquery mobile'的minHour选项;s的日期框
- 如何正确设置jQuery日历小部件的区域设置
- 如何设置jQuery函数的动画's循环中的变量
- 设置 Jquery 对话框标题栏样式
- 如何使用JQuery.Load访问Div中加载URL的UL“id”,“name”等,以设置JQuery树视图
- 如何在页面加载时设置 jquery 切换关闭
- 根据 HTML 表单 ID 值动态设置 jquery 选择器
- 在 jquery 表单序列化变量中设置 jquery 延迟
- 设置 jQuery 动画的队列长度
- 从 html 数据设置 jquery 延迟
- 设置JQuery动画中的超时
- 根据 C# 值设置 jQuery cookie 的值
- 无法设置 jquery 对话框.InnerHtml(某些内容)无需刷新页面