gpt4 book ai didi

javascript - 如果在此之前发生的 mousedown 事件延迟它,则模糊事件似乎会丢失

转载 作者:行者123 更新时间:2023-12-01 15:28:08 24 4
gpt4 key购买 nike

这是代码:

<input type="text" onblur="myFunction()">
<div style="border: 1px solid; width:300px;height:300px" onmousedown = "myOtherFunction()">


function myOtherFunction(){
console.log("mousedown on div occurred");
}

function myFunction(){
console.log("blurr occurred");
}

如果我在输入中输入内容并单击 div,这将按预期工作,触发 mousedown之前 blur .但是,如果我只是在 myOtherFunction 中放置一个调试器并打开开发者工具 blur事件不会被触发并且似乎丢失了。可能是因为调试器打开时发生的“延迟”?

https://jsbin.com/qevapocovo/edit?html,js,console,output

最佳答案

这实际上是 Chrome 上的调试器问题:如果您注意到 my recording你看到我点击了出现在网络应用程序中的“播放”按钮,而在 your recording您单击开发人员工具选项卡内的调试器的“播放”按钮。您可以单击访问断点时弹出的页面内“播放”并验证它是否按预期工作?

编辑:
我创建了一个 html 文件以使用相同的代码直接在 Chrome 上运行,但问题仍然存在:

function myOtherFunction(){
debugger
console.log("mousedown on div occurred")
alert("mousedown on div occurred")
}

function myFunction(){
console.log("blurr occurred")
alert("blurr occurred")
}
<input type="text" onblur="myFunction()">
<div style="border: 1px solid; width:300px;height:300px" onmousedown = "myOtherFunction()"></div>


我也在 Safari 上尝试过,并且工作正常。

关于javascript - 如果在此之前发生的 mousedown 事件延迟它,则模糊事件似乎会丢失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61457797/

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