为什么就不显示结果呢
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函数传参</title>
<script type="text/JavaScript">
function test(x, y, z)
{
sum = x + y +z;
document.write(x+"、"+y+"、"+z+"和:"+sum+"<br/>");
}
test(5, 20, 40.555)
</script>
</head>
<body>
</body>
</html>
看看自己的代码有木有问题,提供一份参考吧。
<!DOCTYPE HTML> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>函数传参</title> <script type="text/JavaScript"> function add3(x,y,z) { var x = parseInt(prompt("请输入第一个数:")); var y = parseInt(prompt("请输入第二个数:")); var z = parseInt(prompt("请输入第三个数:")); sum = x + y +z; document.write(x+"、"+y+"、"+z+"和:"+sum+"<br/>"); } </script> </head> <body> <input type="button" onclick="add3()"> </body> </html>