是否有 onclick 结束事件?
Is there an event for onclick end?
我有一段代码只能在 onclick 事件之后执行。在移动设备上很好,因为我使用 touchstart 和 touchend。电脑上有类似touchend的事件吗?
我的代码目前看起来类似于..
document.getElementById('trigger-box').addEventListener(function(e) {
// the event will be used later
// my code
});
我曾尝试在互联网上搜索答案,但遗憾的是找不到答案。因此,我在这里发布了我的问题。
onmouseup
发生在之前 click
事件执行
<button onclick="console.log(1)" onmouseup="console.log(2)">test</button>
因此,我能想到的唯一解决方法是在 click
事件完成时手动调用
function myClick()
{
console.log('This is in click');
afterClick();
}
function afterClick()
{
console.log('This is after click');
}
<button onclick="myClick()" >test</button>
根据评论:
document.getElementById('trigger-box').addEventListener("mouseup", function(e) {
// the event will be used later
// my code
});
我有一段代码只能在 onclick 事件之后执行。在移动设备上很好,因为我使用 touchstart 和 touchend。电脑上有类似touchend的事件吗?
我的代码目前看起来类似于..
document.getElementById('trigger-box').addEventListener(function(e) {
// the event will be used later
// my code
});
我曾尝试在互联网上搜索答案,但遗憾的是找不到答案。因此,我在这里发布了我的问题。
onmouseup
发生在之前 click
事件执行
<button onclick="console.log(1)" onmouseup="console.log(2)">test</button>
因此,我能想到的唯一解决方法是在 click
事件完成时手动调用
function myClick()
{
console.log('This is in click');
afterClick();
}
function afterClick()
{
console.log('This is after click');
}
<button onclick="myClick()" >test</button>
根据评论:
document.getElementById('trigger-box').addEventListener("mouseup", function(e) {
// the event will be used later
// my code
});