You can use the preventDefault() method on the event object to prevent the default behaviour of an event, such as preventing a form from submitting or a link from navigating.
preventDefault()