我有这个代码:
<input id = "input" type = "text" placeholder = "Type 'Help1' for actions"/>
<button onclick="button()">Confirm</button>
<p id="message"></p>
<script>
function button() {
var text;
var textInput = input.value;
switch (textInput) {
case "Help1":
text = "[Page 1 of 2. Type 'Help2' for page 2] Commands you can use: <ul><li>South</li><li>North</li><li>East</li><li>West</li><li>North Again</li><li>South again</li>";
break;
case "Help2":
text = "[Page 2 of 2] Commands you can use: <li>North One More</li><li>East Once More</li><li>West Once More</li><li>South Once More</li><li>East Again</li><li>West Again</li>";
break;
case "South":
text = "You went to the city; street 2. Do you want to explore?";
break;
}
}
</script>
现在说我想补充一下我对南方的看法。如您所见,有一个问题(请注意:在此之后还有其他情况)。我想添加类似“是”或“否”之类的内容,如果我输入“是”,它会给我类似“你玩得开心”之类的内容。也不给我,“你决定不去探索南街 2 号。
有没有做这样的事情?我尝试开始另一个案例,但没有成功。案例中的 if 和 else if 语句也不做。任何反馈将不胜感激。
holdtom
郎朗坤
相关分类