const clickEvent = (function() {

  if ('ontouchstart' in document.documentElement === true)
    return 'touchstart';
  else
    return 'click';
})();
 
Button.addEventListener(clickEvent, e => {
  console.log("things happened!")
})

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2022-12-23
  • 2022-01-24
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2018-03-10
  • 2021-09-11
  • 2021-12-02
  • 2021-06-29
  • 2022-12-23
  • 2021-11-22
相关资源
相似解决方案