![Prevent the default action of an event](https://javascriptsource.com/wp-content/uploads/2021/08/Prevent-the-default-action-of-an-event-702x526.jpg)
Use the preventDefault()
method. This method works with inline attribute.
<button type="submit" onclick="event.preventDefault()">Click</button>
and event handlers:
ele.onclick = function(e) {
e.preventDefault();
// Do some thing
...
};
ele.addEventListener('click', function(e) {
e.preventDefault();
...
});