<!DOCTYPE html>
<html>
<body>
<h1> Slap Jack </h1>
<p id="message"> </p>
<button type="button" onclick="investMoney()"> How much money are you betting? </button>
<script type="text/javascript">
var gambledMoney;
var money;
var investMoney = function() {
gambledMoney = prompt("How much?");
document.getElementById("message").innerHTML = gambledMoney;
};
var totalAmount;
var card;
var pullCard = function() {
card = Math.floor(Math.random() * 14 + 1);
totalAmount = +card;
document.getElementById("test").innerHTML = card + " " +
"Do you want to pull again?";
document.getElementById("p").innerHTML = "Total points" + " "
totalAmount;
};
</script>
<p id="test"> </p>
<p id="p"> </p>
<button type="button" onClick="pullCard()"> click me to pull a card </button>
</body>
</html>
卡是随机的,当您定义卡时它会显示卡片。我还想要显示你需要显示多少点。当我尝试运行代码时,没有任何反应。
答案 0 :(得分:0)
第22行时出现错误。字符串连接符号[+]丢失。