gpt4 book ai didi

javascript - 如何选中表格中输入文本焦点的复选框

转载 作者:行者123 更新时间:2023-11-30 09:32:41 25 4
gpt4 key购买 nike

我正在尝试在输入文本的焦点上检查表 DOM 中的复选框,但我无法访问该复选框元素,但我的焦点有效

这是我的 jsfiddle 链接 https://jsfiddle.net/9qha9vft/

这是我的代码

Jquery代码

$("td .focus-evt").focus(function() {

$(this).siblings("td input.flat").prop('checked', true);;

});

最佳答案

您的输入框和复选框不是 sibling ,它们在不同的 TD 中。

到最近的TR,然后找到TD和checkbox

$("td .focus-evt").focus(function() {
$(this).closest('tr').find("td input.flat").prop('checked', true);;
});

FIDDLE

关于javascript - 如何选中表格中输入文本焦点的复选框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45358888/

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