by Anonymous » 19 Aug 2025, 21:45
Ich erstelle ein Quiz für meine Webseite. Ich habe eine Funktion an der ersten Frage. Wobei ein Knopf "Lösung anzeigen" heißt. Nach dem Klicken wird das Element angezeigt. Derzeit ändert die Schaltfläche nicht den Schaltflächentext in "Lösung aus", sobald er angezeigt wurde. Und wenn ich auf Lösung klicke, wird die erste Frage angezeigt. PrettyPrint-Override ">
Code: Select all
function show_hide() {[b] var myAnswer = document.getElementById('answer');
var displaySetting = myAnswer.style.display;
var quizButton = document.getElementsByClassName('quiz-button');
if (displaySetting == "inline-block") {
myAnswer.style.display = 'none';
quizButton.innerHTML = 'Show Answer';
} else {
myAnswer.style.display = 'inline-block';
quizButton.innerHTML = 'Hide Answer';
}
}< /code>
.quiz-question {
margin-bottom: 10px;
text-align: left;
font-size: 15px;
color: #f44336;
font-weight: 400;
}
.quiz-button {
display: inline-block;
text-decoration: none;
color: #111;
border: 1px solid #f44336;
padding: 5px 5px;
font-size: 13px;
background: transparent;
position: relative;
cursor: pointer;
}
.quiz-button:hover {
color: #fff;
background: #f44336;
transition: 0.5s;
}
#answer {
display: none;
}< /code>
Chapter 1.1 End of Topic Quiz
The following quiz is meant to reinforce your understanding of the material presented above.
[h4]1. What is a statement? [/h4]
Show Solution
A statement[/b] is an instruction in a computer program that tells the computer to perform an action.[b]
[h4]2. What is a function? [/h4]
Show Solution
A function[/b] is several statements that are executed sequentially.
Ich erstelle ein Quiz für meine Webseite. Ich habe eine Funktion an der ersten Frage. Wobei ein Knopf "Lösung anzeigen" heißt. Nach dem Klicken wird das Element angezeigt. Derzeit ändert die Schaltfläche nicht den Schaltflächentext in "Lösung aus", sobald er angezeigt wurde. Und wenn ich auf Lösung klicke, wird die erste Frage angezeigt. PrettyPrint-Override ">[code]function show_hide() {[b] var myAnswer = document.getElementById('answer');
var displaySetting = myAnswer.style.display;
var quizButton = document.getElementsByClassName('quiz-button');
if (displaySetting == "inline-block") {
myAnswer.style.display = 'none';
quizButton.innerHTML = 'Show Answer';
} else {
myAnswer.style.display = 'inline-block';
quizButton.innerHTML = 'Hide Answer';
}
}< /code>
.quiz-question {
margin-bottom: 10px;
text-align: left;
font-size: 15px;
color: #f44336;
font-weight: 400;
}
.quiz-button {
display: inline-block;
text-decoration: none;
color: #111;
border: 1px solid #f44336;
padding: 5px 5px;
font-size: 13px;
background: transparent;
position: relative;
cursor: pointer;
}
.quiz-button:hover {
color: #fff;
background: #f44336;
transition: 0.5s;
}
#answer {
display: none;
}< /code>
Chapter 1.1 End of Topic Quiz
The following quiz is meant to reinforce your understanding of the material presented above.
[h4]1. What is a statement? [/h4]
Show Solution
A statement[/b] is an instruction in a computer program that tells the computer to perform an action.[b]
[h4]2. What is a function? [/h4]
Show Solution
A function[/b] is several statements that are executed sequentially.
[/code]