任何人都可以更正此代码?

时间:2015-10-18 10:48:38

标签: javascript html

我无法执行此代码。我尝试了很多次但都没有成功。

<html>
<head><title>
alvin</title>
<script type = "text/javascript">
var voting age = window.prompt("please enter your age");
if(voting age>=18)
{
    document.write("you are eligible to vote");
}
else
{
    document.write("you are not eligible to vote");
}

</script>
</head>
</html>

1 个答案:

答案 0 :(得分:0)

冷静下来的孩子不要在考试紧张中做饭,你唯一需要知道的是变量没有空间所以我只是用voting age替换voting_age

<html>
<head><title>
alvin</title>
<script type = "text/javascript">

var voting_age = window.prompt("please enter your age");
if(voting_age>=18)
{
    document.write("you are eligible to vote");
}
else
{
    document.write("you are not eligible to vote");
}

</script>
</head>
</html>