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();
...
});