gpt4 book ai didi

javascript - 如何 Onload() 将焦点设置到 jQuery Handsontable

转载 作者:行者123 更新时间:2023-11-28 21:01:12 26 4
gpt4 key购买 nike

将焦点设置为 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();
});

非常非常感谢!

最佳答案

感谢您的请求。现在有一个公共(public)方法可以做到这一点。

在按钮上使用它:

$('#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/

关于javascript - 如何 Onload() 将焦点设置到 jQuery Handsontable,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11007947/

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