event.isDefaultPrevented()S2C Home « Objects « event.isDefaultPrevented()

Event default action checker method.

Description

The event.isDefaultPrevented() Event object method returns a boolean dependant upon event.preventDefault() ever being called on this event object.

Syntax

Signature Description
event.isDefaultPrevented()Returns a boolean dependant upon event.preventDefault() ever being called on this event object.

Parameters

None.

Return

A Boolean object.

event.isDefaultPrevented() ExampleTop

Return a boolean dependant upon event.preventDefault() ever being called on this event object.

In the example below we show two new messages in the 'div' element with an id of 'div8' the first time the mouse is clicked on this element. One before event.preventDefault() has been called and one after.


$(function(){
  $('#div8').one('click', function(event) {
     $('#div8').append('Has event.preventDefault() been called on this event object? ' 
                      + event.isDefaultPrevented() + '<br/>');
     event.preventDefault();
     $('#div8').append('Has event.preventDefault() been called on this event object? ' 
                      + event.isDefaultPrevented() + '<br/>');
  });
});

div8. Some initial text.