我正在查看一些简单的Javascript,有人可以帮助您找出问题所在,我是JS的新手,所以我确定这很简单,我已经错过了,但是当我加载页面时,它保持空白并且什么都没有负载?
任何帮助深表感谢。
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<script>
var numx = prompt("enter your first number");
var numy = prompt("enter your second number");
var oper = prompt("enter one of the following operations you would like done to your two numbers, +, -, /, *");
var answer = 0;
if(oper == "+")
{
answer = (numx + numy);
}
else if(oper == "-")
{
answer = (numx - numy);
}
else if(oper == "*")
{
answer = (numx * numy);
}
else (oper == "/")
{
answer = (numx / numy);
}
document.write("<p>the answer is " + answer "</p>");
</script>
</body>
</html>
document.write("<p>the answer is " + answer + "</p>");
这是一个小提琴,它写入现有文档元素而不是document.write。 https://jsfiddle.net/49yuod7w/