xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

how to using js get addEventListener bind events length

how to using js get addEventListener bind events length


const btn = document.querySelector('#btn');

btn.addEventListener('click', () => {
  const url = 'http://localhost:9000/api/post';
  const obj = {
      "user": "1",
      "os": "macOS"
  };
  let data = new URLSearchParams(obj);
  navigator.sendBeacon(url, data);
});

btn.addEventListener('click', () => {
  const url = 'http://localhost:9000/api/post';
  const obj = {
      "user": "12",
      "os": "macOS"
  };
  let data = new URLSearchParams(obj);
  navigator.sendBeacon(url, data);
});


// ???

btn.eventsLength ?? 0;


addEventListener

target.addEventListener(type, listener);
target.addEventListener(type, listener, options);
target.addEventListener(type, listener, useCapture);
target.addEventListener(type, listener, useCapture, wantsUntrusted); // wantsUntrusted is Firefox only

https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener

https://www.freecodecamp.org/news/javascript-addeventlistener-example-code/

target.removeEventListener(event, function, useCapture);

visual event

http://www.sprymedia.co.uk/article/Visual+Event
http://www.sprymedia.co.uk/article/Visual+Event+2

refs

https://stackoverflow.com/questions/446892/how-to-find-event-listeners-on-a-dom-node-when-debugging-or-from-the-javascript



©xgqfrms 2012-2020

www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!


posted @ 2021-04-10 08:33  xgqfrms  阅读(74)  评论(2编辑  收藏  举报