Untitled
unknown
plain_text
2 years ago
847 B
9
Indexable
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);
}Editor is loading...
Leave a Comment