You are here: Reference > JavaScript > client-side > event handling > properties > type (event)

type property (event)

Browser support:
Retrieves a string that represents the type of the event, such as "mouseout", "click", etc.
This property can be useful when the same handler function is registered for different type of events. In that case, the type property helps to identify what type of event has occurred.


You can find the related objects in the Supported by objects section below.
This property is read/write.

Possible values:

String that represents the type of the event.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the type property:
    <script type="text/javascript">
        function GetEventType (event) {
            if (event.type == "click") {
                alert ("You have clicked on the button");
            if (event.type == "mouseover") {
                alert ("You have moved the mouse over");
    <button onclick="GetEventType (event);">Click on this button!</button>
    <button onmouseover="GetEventType (event);">Move the mouse over!</button>
Did you find this example helpful? yes no

Supported by objects:

External links:

User Contributed Comments

Post Content

Post Content