JSFiddle - React, Tailwind, and code Playground
HTML
Wie heißt der Kaiser von
<input type="text" id="input_answer" value="" onChange="checkInput(this)" />
<DIV id="answer"></DIV>
CSS
.wrong {
display: block;
color: red;
}
.correct {
display: block;
color: green;
}
JavaScript
function checkInput(el){
var target = document.getElementById("answer");
if(el.value.toLowerCase() == "china"){
target.innerText = "KORREKT";
target.setAttribute("class","correct");
}else{
target.innerText = "FALSCH";
target.setAttribute("class","wrong");
}
}