You need to assign the "type" attribute to the "button" element. Like below:
var btn = document.getElementById("btn");
btn.onclick = function(e) {
e.preventDefault();
debugger;
alert(123);
}
<form action="javascript:void(0)">
<input type="text"/>
<button type="button" id="btn">Submit</button>
</form>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…