Untitled

mail@pastecode.io avatar
unknown
plain_text
15 days ago
847 B
2
Indexable
Never
function logAllEvents(element) {
  // List of all standard DOM events
  const events = [
    "click", "dblclick", "mousedown", "mouseup", "mousemove", "mouseover", "mouseout",
    "mouseenter", "mouseleave", "keydown", "keypress", "keyup",
    "focus", "blur", "change", "input", "submit", "reset",
    "drag", "dragstart", "dragend", "dragover", "dragenter", "dragleave", "drop",
    "scroll", "resize", "wheel", "contextmenu", "select",
    "touchstart", "touchmove", "touchend", "touchcancel"
  ];

  events.forEach(eventType => {
    element.addEventListener(eventType, function(event) {
      console.log(`Event: ${eventType}`, event);
    });
  });
}

// Example usage:
// Assuming you want to log all events on a button with the ID 'myButton'
const myButton = document.getElementById('myButton');
if (myButton) {
  logAllEvents(myButton);
}
Leave a Comment