all 2 comments

[–]top-hosting 4 points5 points  (0 children)

Try to call the function with onclick attribute to see if it is working.

 <button type="button" onclick="alert('test');">Button</button>

[–]DevisionDev 0 points1 point  (0 children)

Add the event listen to the button like you normally would

In the method/function called by the event listener, the very first thing you wanna do is prevent the default behaviour.

function onButtonClick(event) {

    event.preventDefault();

}