该守则应当要求用户提供意见,并根据提交的说明(正确的答案是“Aconcagua”)来退回不正确或正确。 在进行并提交答复时,均不将这些答复印在屏幕上。 我很抱着耳光和超音。
function wrong2()
{
document.querySelector( #2solution ).innerHTML = "Incorrect.";
document.querySelector( #input ).style.backgrounColor = red ;
}
function right2()
{
document.querySelector( #2solution ).innerHTML = "Correct!";
document.querySelector( #input ).style.backgrounColor = green ;
}
a = "Aconcagua";
document.querySelector( #form ).addEventListener( submit , function(event){
if (document.querySelector( #input ).value.localeCompare(a) == 0)
{
right2();
}
else
{
wrong2();
}
event.preventDefault();
});
<div class="wrapper">
<div class="header">
<h1>Trivia!</h1>
</div>
<div class="section">
<h2>Part 2: Free Response</h2>
<hr>
<h3>What is the highest mountain in South America?</h3>
<form action="" id="form">
<input id="input" type="text">
<button id="b" type="sumbit">Submit</button>
</form>
</div>
<h2 id="2solution"></h2>
</div>