<html>
<head>
<title>The greatest MMO you will ever play</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<body>
<script>
function buyStuffWithPoints()
{
var points=prompt("How many points have you earned?");
document.write("<p>Buy your items now and prepare for battle! Choose wisely.<p>");
document.write("<p><img src = 'sword.jpg'/><p>");
document.write("<p><img src = 'Waterskin.jpg' /><p>");
document.write("<p><img src = 'charm.jpg' /><p>");
document.write("<p><img src = 'Phone.jpg' /><p>");
}
</script>
<input type="button" onclick="buyStuffWithPoints()" value="Start!" />
<div>
<input type="button" onclick="buyStuffWithPoints()" value="Buy Sword(2500)!" />
</div>
</body>
</html>
所以目前发生的是当我运行它时,它会提示我输入点数,然后显示两个按钮“Start!”和“买剑(2500)!”。然后点击开始后,下一页显示4张要购买的图片。如何在第二页上创建按钮?
我想要发生的是,在输入点数之后,我只想让它显示“开始!”按钮。然后在NEXT页面上显示图片的同一页面,我想显示“Buy Sword”按钮。
我明白为什么这样做,我只是不知道如何改变它。谁能帮我这个?
你[真的不应该使用'document.write'(http://stackoverflow.com/questions/802854 /为什么 - 是 - 文档写入认为,一个坏实践)。除此之外,一旦您获得正确的DOM操作,在一页上完成这一切可能会更容易。 –