单击按钮时不会触发JavaScript函数

Dan*_*iel 2 javascript function onclick

我刚刚开始自学JavaScript,正在做一些基本的练习.现在我正在尝试创建一个函数,它接受三个值并打印出最大值.但是,该功能在按钮点击时拒绝触发.我尝试制作一个单独的,非常简单的函数,仅用于调试,它也拒绝触发.我已经用几乎完全相同的方式编写了其他练习函数(它们有两个参数,而不是三个参数),工作正常.任何见解将不胜感激.

<!DOCTYPE HTML>
<html>
<head>
<script type = "text/javascript">
<!--

//Define a function Max() that takes three numbers as 
//arguments and returns the largest of them.
function Boo(){
    document.write("boo");
    alert("boo");
}


function Max(p1, p2, p3){
    document.write(p1+p2+p3);
    alert('BOO!')

    document.write(document.getElementById('value1').value);

    var max = Number(p1);
    v2 = Number(p2):
    v3 = Number(p3);    

    if (v2 > max)
        max = v2;
    if (v3 > max)
        max = v3;

    document.write(max);
}
-->
</script>
    </head>
    <body>
<form>
    <input type="text" id="value1" name="value1"/><br />
    <input type="text" id="value2" name="value2"/><br />
    <input type="text" id="value3" name="value3"/><br />
    <input type = "button" 
    onclick="Boo()" 
    value = "Compare!"/>
    <!-- onclick="Max(document.getElementById('value1').value,
                 document.getElementById('value2').value,
                 document.getElementById('value3').value)" -->
</form>
  </body>
 </html>
Run Code Online (Sandbox Code Playgroud)

aqu*_*nas 5

  v2 = Number(p2):
Run Code Online (Sandbox Code Playgroud)

应该

v2 = Number(p2);
Run Code Online (Sandbox Code Playgroud)

另外,请查看开发人员工具,了解您使用的任何浏览器,以找到这样的简单语法错误.(在大多数浏览器中,您可以按F12键).