我試圖阻止提交使用提交eventlistener的表單。我的匿名函數運行,但表單仍然提交,即使函數結束時返回false。沒有JS錯誤被拋出。用提交eventlistener停止表單提交
我在犯些愚蠢的錯誤嗎?
<form id="highlight">
Row: <input type="text" name="rows" value="1" id="rows">
Column: <input type="text" name="cells" value="1" id="cells">
<input type="submit" name="Submit" value="Highlight" id="Submit">
</form>
<script>
var highlight_form = document.getElementById('highlight');
highlight_form.addEventListener('submit', function() {
alert('hi');
return false;
}, false);
</script>
[addEventListener提交表單返回false仍然可以提交表單?](http://stackoverflow.com/questions/4924036/return-false-on-addeventlistener-submit-still-submits-the-form) – unor 2013-09-16 11:38:18