Javascript 我不知道如何做出两个选择,然后展示你的选择
好了,现在就是这样。 评论“从这里开始”的部分给我带来了麻烦。其余的工作方式我也想要,但我不能为我的生活得到这个。我已经在谷歌上搜索过很多次了,我的java课程和编码课程都被登上了广告Javascript 我不知道如何做出两个选择,然后展示你的选择,javascript,html,if-statement,Javascript,Html,If Statement,好了,现在就是这样。 评论“从这里开始”的部分给我带来了麻烦。其余的工作方式我也想要,但我不能为我的生活得到这个。我已经在谷歌上搜索过很多次了,我的java课程和编码课程都被登上了广告 <!DOCTYPE html> <html> <head> </head> <body> <h1>Text adventure</h1> <p>By Caleb Scott Sanders</p>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h1>Text adventure</h1>
<p>By Caleb Scott Sanders</p>
<p id="1"></p>
<p id="2"></p>
<p id="3"></p>
<script>
document.getElementById("demo").innnerHTML = confirm("Sup");
</script>
<script>
document.getElementById("1").innerHTML = "you wake up in a dark and dusty room, its cramped and only two potential exits. The door or the window.";
document.getElementById("2").innerHTML = "1: check door 2: check window";
</script>
<script>//From here
document.getElementById("demo").innerHTML =
choice = prompt();
if(choice = a){
document.getById("3").innerHTML = "The door has a large iron lock with equaly large bars. This seams more like a cell gate than a door...";
} else if(choice = b) {
document.getById("3").innerHTML = "The window is open but looks too small to crawl through. No way out from here.";
};
</script>
<p id="3"></p>// to here is the problem
</body>
</html>
文本冒险
卡莱布·斯科特·桑德斯
document.getElementById(“demo”).innnerHTML=confirm(“Sup”);
document.getElementById(“1”).innerHTML=“当你醒来时,房间又黑又满是灰尘,很拥挤,只有两个可能的出口。门或窗。”;
document.getElementById(“2”).innerHTML=“1:检查门2:检查窗”;
//从这里
document.getElementById(“demo”).innerHTML=
选择=提示();
如果(选项=a){
document.getById(“3”).innerHTML=“这扇门有一把同样大的铁锁,它的接缝更像一扇牢房门,而不是一扇门……”;
}否则如果(选项=b){
document.getById(“3”).innerHTML=“窗口是打开的,但看起来太小,爬不过去。从这里没有出路。”;
};
//问题出在这里
请告诉我我做错了什么,因为我做不到。问题在于几件事
document.getElementById(“demo”).innerHTML=
,但我不知道getElementById
而不是getById
文本冒险
卡莱布·斯科特·桑德斯
document.getElementById(“demo”).innnerHTML=confirm(“Sup”);
document.getElementById(“1”).innerHTML=“当你醒来时,房间又黑又满是灰尘,很拥挤,只有两个可能的出口。门或窗。”;
document.getElementById(“2”).innerHTML=“1:检查门2:检查窗”;
var choice=prompt();
如果(选项==“a”){
document.getElementById(“3”).innerHTML=“这扇门有一把同样大的铁锁,它的接缝更像一扇牢房门,而不是一扇门……”;
}否则如果(选项==“b”){
document.getElementById(“3”).innerHTML=“窗口已打开,但看起来太小,无法爬行通过。从这里没有出路。”;
};
问题在于几件事
document.getElementById(“demo”).innerHTML=
,但我不知道getElementById
而不是getById
文本冒险
卡莱布·斯科特·桑德斯
document.getElementById(“demo”).innnerHTML=confirm(“Sup”);
document.getElementById(“1”).innerHTML=“当你醒来时,房间又黑又满是灰尘,很拥挤,只有两个可能的出口。门或窗。”;
document.getElementById(“2”).innerHTML=“1:检查门2:检查窗”;
var choice=prompt();
如果(选项==“a”){
document.getElementById(“3”).innerHTML=“这扇门有一把同样大的铁锁,它的接缝更像一扇牢房门,而不是一扇门……”;
}否则如果(选项==“b”){
document.getElementById(“3”).innerHTML=“窗口已打开,但看起来太小,无法爬行通过。从这里没有出路。”;
};