gpt4 book ai didi

javascript - 响应未显示 ID 屏幕?

转载 作者:行者123 更新时间:2023-12-02 23:57:19 29 4
gpt4 key购买 nike

我正在尝试以 HW 身份进行测验。我输入的回复应该会出现在屏幕上,但事实并非如此。我使用函数response()多次检查了“15”行和“17”行中出了什么问题。我没有发现任何错误,需要调试和编写正确语法方面的帮助。

有什么需要重写的吗?谢谢。

我尝试了多次检查语法错误。

function responseYes() {
document.getElementById('screen').InnerHTML = "You are correct!"
}

function responseNo() {
document.getElementById('screen').InnerHTML = "You are wrong~~"
}
body,
html {
width: 100%;
height: 100%;
margin: 0;
background-image: linear-gradient(#613AAB, #613);
color: antiquewhite;
font-weight: normal;
}

h1,
h2 {
font-weight: normal;
text-align: center;
}

#screen {
width: 80%;
border: 1px solid #E8C8F0;
margin: auto;
display: table;
padding: 1%
}

.Answers {
width: 47%;
font-size: 13pt;
color: darkred;
background-color: rgba(255, 255, 255, .5);
float: left;
margin: .15%;
padding: 1%;
border-radius: 5px;
}

.Answers p {
position: relative;
margin: 3% 0;
}

.Answers:hover {
background-color: rgba(255, 255, 255, .8)
}
<body>
<div id="screen">
<h1>Quiz Mania</h1>
<h2>Who wants to rap with kermit?</h2>
<a href="#" onClick="responseYes()">
<div class="Answers">
<p>Me</p>
</div>
</a>
<a href="#" onClick="responseNo()">
<div class="Answers">
<p>A dog pissing at outside</p>
</div>
</a>
<a href="#" onClick="responseNo()">
<div class="Answers">
<p>space</p>
</div>
</a>
<a href="#" onClick="responseYes()">
<div class="Answers">
<p>pencil</p>
</div>
</a>
</div>
</body>

最佳答案

<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<style>
body,html{width:100%; height:100%; margin:0; background-image:linear-gradient(#613AAB,#613); color:antiquewhite; font-weight:normal;}
h1,h2{font-weight:normal; text-align: center;}
#screen{width:80%; border:1px solid #E8C8F0; margin:auto; display:table; padding: 1%}
.Answers{width:47% ; font-size:13pt; color:darkred; background-color:rgba(255,255,255,.5); float:left; margin:.15%; padding: 1%; border-radius: 5px;}
.Answers p{position: relative; margin: 3% 0;}
.Answers:hover{background-color: rgba(255, 255, 255, .8)}
</style>
<script>
function responseNo() {
document.getElementById("screen").innerHTML = "You are wrong~~";
}

function responseYes() {
document.getElementById("screen").innerHTML = "You are correct!";
}
</script>
</head>

<body>
<div id="screen">
<h1>Quiz Mania</h1>
<h2>Who wants to rap with kermit?</h2>
<a href="#" onclick="responseYes()"><div class="Answers"><p>Me</p></div></a>
<a href="#" onclick="responseNo()"><div class="Answers"><p>A dog pissing at outside</p></div></a>
<a href="#" onClick="responseNo()"><div class="Answers"><p>space</p></div></a>
<a href="#" onClick="responseYes()"><div class="Answers"><p>pencil</p></div></a>
</div>
</body>
</html>

这会对你有所帮助:)

这是因为InnerHTML中的大写I

关于javascript - 响应未显示 ID 屏幕?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55315361/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com