What is an Event Object in jQuery?

The callback function takes a single parameter; when the handler is called the JavaScript event object will be passed through it.

The event object is often unnecessary and the parameter is omitted, as sufficient context is usually available when the handler is bound to know exactly what needs to be done when the handler is triggered, however there are certain attributes which you would need to be accessed.

Let us see an example of isDefaultPrevented() method. The isDefaultPrevented() method checks whether event.preventDefault() was ever called on this event object.


You can try to run the following code to learn how to work with even object in jQuery:

Live Demo


      <title>jQuery isDefaultPrevented() method</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
         $(document).ready(function() {
               if ( event.isDefaultPrevented() ){
                  alert( "Default behavior is disabled - 1" );
                  alert( "Default behavior is enabled - 1" );
               if ( event.isDefaultPrevented() ){
                  alert( "Default behavior is disabled - 2" );
                  alert( "Default behavior is enabled - 2" );
      <span>Click the following link and it won't work:</span>
      <a href = "https://www.google.com">GOOGLE Inc.</a>

Updated on: 11-Dec-2019


Kickstart Your Career

Get certified by completing the course

Get Started