Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML | DOM createEvent() Event Method

  • Last Updated : 24 Jul, 2019

The createEvent() method in HTML creates an event object of the specified type. The created event must be initialized before use.


document.createEvent( event_type )

event_type: It is the required parameter and used to specify the type of event.

There are many type of events which are listed below:

  • AnimationEvent
  • ClipboardEvent
  • DragEvent
  • FocusEvent
  • HashChangeEvent
  • InputEvent
  • KeyboardEvent
  • MouseEvent
  • PageTransitionEvent
  • PopStateEvent
  • ProgressEvent
  • StorageEvent
  • TouchEvent
  • TransitionEvent
  • UiEvent
  • WheelEvent

Below program illustrates the createEvent() method in HTML:


<!DOCTYPE html>
            DOM createEvent() Event Method
            div {
                background-color: green;
                color: white;
            document.body.onclick = function() {
                            = "Welcome to GeeksforGeeks!";
            var onClick = function() {
                var evt = document.createEvent("MouseEvents");
                    ("click", true, true, window, 0, 0, 0, 0,
                    0, false, false, false, false, 0, null);
        <div id = "Geeks"></div>

Before Click on the element:

After Click on the element:

Supported Browsers: The browser supported by DOM createEvent() method are listed below:

  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!