此触发器一次正常工作。如果再次触发,它只会刷新我的页面,所以我猜到preventDefault无法正常工作。我想念什么吗?
function watchForm() {
$(‘form’).submit(event => { //listening for event on the form pop-up menu
event.preventDefault(); //suppresses browser from going to a linked page.
$(’#js-error-message’).empty();
let searchState = $(’#js-stateMenuForm :selected’).val();
getParks(searchState); //calls getParks function.
});
}