The preventDefault() method is used to stop any element form behaving its default behaviour. For example, if we have a hyperlink linked to a particular location. Using preventDefault() function we can restrict it from navigating to it the by a custom location in our javascript. You can use the method isDefaultPrevented to know whether this method was ever called (on that event object).