Skip to content

Instantly share code, notes, and snippets.

@gerwld
Created December 8, 2024 09:55
Show Gist options
  • Save gerwld/6c733026f9f3576a7b5450e98b8915ec to your computer and use it in GitHub Desktop.
Save gerwld/6c733026f9f3576a7b5450e98b8915ec to your computer and use it in GitHub Desktop.
Trigger any event placed in IIFE / etc
const element = temp1;
// Create a 'mouseenter' event
const event = new MouseEvent('mouseover', {
bubbles: true, // Ensures the event bubbles up (if needed)
cancelable: true, // Allows the event to be canceled
view: window // Links the event to the window object
});
// Dispatch the event on the element
element.dispatchEvent(event);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment