我想在用户完成信息输入后显示用户输入的内容。当用户到达最后一个提示时,我希望页面显示他们输入的内容。例如:如果他们在名称部分下输入 apples,我希望它在底部代码的 P1 部分中列出单词 apples。我是 javascript 的新手,提前知道我的代码很不稳定,但我正在学习,所以请对我放轻松,请帮助我弄清楚如何在 javascript 完成后显示用户输入。
我的代码:
<!DOCtype html>
<html>
<head>
<title> This will display some answers </title>
<body>
<script type="text/javascript">
var user = prompt("Welcome to learning about allocations with me, mr fields.
In this tutorial we will be learning about alloction exceptions and what not
to do with them. Let's get started, shall we? ").toUpperCase();
switch(user){
case 'YES':
var user_1 = prompt("What's your name?");
switch(user_1) {
case 'Buster':
prompt("Hey, brother!");
break;
case 'Alex':
prompt("I've made a huge mistake.");
break;
case 'Steve':
prompt("Steve Holt!");
break;
default:
prompt("I don't know you!");}
break;
default:
prompt("too bad!");
}
</script>
</body>
</head>
<h1> answer </h1>
<p1> "answers should go here" </p1>
</html>
var user_1 = prompt("What's your name?");
var answerElement = document.getElementById("answer")
answerElement.innerText = user_1;
<p id="answer"></p>
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)