我有HTML和JavaScript代码,在点击提交后必须更改页面。问题是,当我单击提交按钮时,页面保持不变。
感谢您的帮助。
HTML:
function() {
"use strict";
var state = document.getElementById('state');
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('cart').addEventListener('submit', estimateTotal);
var btnEstimate = document.getElementById('submit');
btnEstimate.disabled = true;
state.addEventListener('change', function() {
if (state.value === '') {
btnEstimate.disabled = true;
} else {
btnEstimate.disabled = false;
}
});
});
function estimateTotal(event) {
event.preventDefault();
if (state.value === '') {
alert('Please choose your shipping state.');
state.focus();
}
}
})();
JavaScript的:
x