点击它时,我的按钮无法正常工作的任何特殊原因?这是代码。
<script>
function save() {
if (isNaN(document.form.result.value) || document.form.result.value == 0) {
document.getElementById('hours').innerHTML = "There was an input error, make sure that: <br> The calculator field is not empty <br> Only include numbers as an input";
document.getElementById('hoursdiv').style.background = "yellow";
} else {
savedvalue = document.form.result.value;
document.getElementById('hours').innerHTML = "Hours Worked This Week: " + savedvalue;
document.getElementById('hoursdiv').style.background = "";
}
}
function clear() {
alert("hi");
}
</script>
<div>
<!-- Save Button -->
<input class = "customSubmitButton" type="button" onClick="save();" value="Save">
<!-- Clear Button -->
<input class = "customSubmitButton" type="button" onClick = "clear()" value = "Clear">
<div id = "hoursdiv">
<p>
<strong id = "hours"> </strong>
</p>
</div>
</div>
“保存”按钮工作正常。