Tutorialspoint.dev

jQuery | event.type property with Examples

The event.type is an inbuilt property in jQuery which is used to return which event type is started.
Syntax:

event.type

Parameter: It does not accept any parameter because it is a property not a function.
Return Value : It returns which event type has been triggered.
jQuery code to show the working of event.type property:

<html>
  
<head>
    <!-- jQuery code to show the working of this property -->
    </script>
    <script>
        $(document).ready(function() {
            $("#div1").on("click dblclick mouseover mouseout",
            function(event) {
                $(".div2").html("Event: " + event.type);
            });
        });
    </script>
    <style>
        #div1 {
            width: 230px;
            height: 100;
            display: block;
            padding: 25px;
            border: 2px solid green;
            font-size: 20px;
        }
          
        .div2 {
            width: 170px;
            margin: 10px;
            height: 50px;
            padding: 10px;
            border: 2px solid green;
        }
    </style>
</head>
  
<body>
    <!-- move mouse over this box -->
    <div id="div1">Do any event in this box !!</div>
    <!-- events are being shown in this box -->
    <div class="div2"></div>
</body>
  
</html>

Output:
Before moving mouse anywhere-

After the mouse is moved over the big box-

After the mouse is moved outside of the big box-



This article is attributed to GeeksforGeeks.org

leave a comment

code

0 Comments

load comments

Subscribe to Our Newsletter