Use Event.preventDefault()
This method tells the user agent that if the event does not get explicitly handled, its default action should not be taken as it normally would be.
The event continues to propagate as usual, unless one of its event listeners calls stopPropagation()
or stopImmediatePropagation()
, either of which terminates propagation at once.
Alternatively, you can use onclick='return false'
(either inline or in a function). It will prevent default browser behaviour (more info):
This approach prevents the event to propagate, though. More details.