gpt4 book ai didi

jQuery mousedown 找到触发事件的确切元素

转载 作者:行者123 更新时间:2023-12-01 06:16:10 27 4
gpt4 key购买 nike

嗨,我有这个 HTML 代码

<th scope="col" class="" style="width: 13px;">
<div class="some-handle"></div>
<a href="javascript:__doPostBack('ucPWP$ctl03$3056$GVReport','Sort$3')">Passengers</a>
</th>

并且有这个JS代码

  $("Table tr th").mousedown(function (e) {  
/*mousedown code goes here... */
/* ignore if mousedown occur on div "some-handle" */
}

现在我 try catch mousedown 是否发生在具有“some-handle”类的 div 上。我可以这样做吗?

最佳答案

检查e.target 。这是事件起源的元素。

if ($(e.target).hasClass('some-handle')) {
// fired on div "some-handle"
}

关于jQuery mousedown 找到触发事件的确切元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6289544/

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