If I do this I can prevent default on form submit just fine:
document.getElementById('my-form').onsubmit(function(e) {
e.preventDefault();
// do something
});
But since I am organizing my code in a modular way I am handling events like this:
document.getElementById('my-form').addEventListener('onsubmit', my_func);
var my_func = function() {
// HOW DO I PREVENT DEFAULT HERE???
// do something
}
How can I prevent default now?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…