我有一段代码,应该只在onclick事件之后执行。在移动设备上它很好,因为我使用了touchstart和touchend。是否有类似于touchend的事件在计算机上使用?
我的代码目前看起来类似于..
document.getElementById('trigger-box').addEventListener(function(e) {
// the event will be used later
// my code
});我试着在网上搜索答案,但不幸的是找不到答案。因此,我在这里发布了我的问题。
发布于 2015-05-30 19:56:35
根据评论:
document.getElementById('trigger-box').addEventListener("mouseup", function(e) {
// the event will be used later
// my code
});发布于 2015-05-30 19:52:40
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>
https://stackoverflow.com/questions/30545776
复制相似问题