gpt4 book ai didi

javascript - 单击 TR 时确定目标 TD

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:05:49 24 4
gpt4 key购买 nike

给定表格行的一些点击事件:

$("tr.somerow").click(function(){
//do some stuff
//can I determine the TD under the cursor at the time of clicking?
})

我能否确定在单击时光标位于哪个 TD(或任何子元素)下?

最佳答案

如果您能够更改脚本,那么请这样做以利用 jquerys .delegate功能。这避免了有多个绑定(bind)的点击事件,并且在事件处理程序中,this 上下文将是被点击的 td 元素的上下文。

$('tr.somerow').delegate('td', 'click', function(){

//this refers to the td

})

关于javascript - 单击 TR 时确定目标 TD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7321100/

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