gpt4 book ai didi

javascript - 为什么 mousedown 不能在 标签上工作?

转载 作者:行者123 更新时间:2023-11-28 14:02:33 25 4
gpt4 key购买 nike

mousedown 事件仅在我单击元素而不是 html 元素时才起作用。为什么以及我能做什么?

var curFocus;
$(document.body).delegate('*','mousedown', function(){
if ((this != curFocus) && // don't bother if this was the previous active element
($(curFocus).is('.field')) // if it was a .field that was blurred
) {
$('.' + $(curFocus).attr("id")).removeClass("visible"); // take action based on the blurred element
}

curFocus = this; // log the newly focussed element for the next event
});

最佳答案

<html>标签有点笼统,它包含不可见的元素,例如 <head> ,尝试使用<body>标签。

关于javascript - 为什么 mousedown 不能在 <html> 标签上工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4209729/

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