preventDefault() Event Method in JavaScript
preventDefault() Event Method in JavaScript
The preventDefault() method is used for canceling an event if it is cancelable. It means that the default action that belongs to the event will not occur. However, all events are not cancelable and to find out those events use the cancelable property. It also does not prevent further propagation, therefore, use stopPropagation() for this purpose.
Syntax:-
Its syntax is:- event.preventDefault()