HTML/CSS/JS: 'Anzeigen' Antwort auf Taste Drücken SieCSS

CSS verstehen
Anonymous
 HTML/CSS/JS: 'Anzeigen' Antwort auf Taste Drücken Sie

Post by Anonymous »

Ich erstelle ein Quiz für meine Webseite. Derzeit habe ich 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. < /P> Das Hauptproblem besteht darin, dass ich mehrere Fragen habe. Und wenn ich auf Lösung klicke, wird die erste Frage angezeigt. class = "snippet">

Code: Select all

         function show_hide()
{
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.



Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post