Prevent click event from firing when dblclick event fires

前端 未结 12 1321
名媛妹妹
名媛妹妹 2020-12-02 20:17

I\'m handling both the click and dblclick event on a DOM element. Each one carries out a different command, but I find that when double clicking on the element, in addition

12条回答
  •  忘掉有多难
    2020-12-02 20:54

    
      const toggle = () => {
          watchDouble += 1;
          setTimeout(()=>{
            if (watchDouble === 2) {
              console.log('double' + watchDouble)
            } else if (watchDouble === 1) {
              console.log("signle" + watchDouble)
            }
            watchDouble = 0
          },200);
    
      }
    

提交回复
热议问题