为什么我的按钮功能不清晰()工作?

时间:2013-07-19 22:26:38

标签: javascript html

点击它时,我的按钮无法正常工作的任何特殊原因?这是代码。

    <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>

“保存”按钮工作正常。

1 个答案:

答案 0 :(得分:7)

尝试更改功能名称。

Is "clear" a reserved word in Javascript?