JSFiddle - React, Tailwind, and code Playground
by jfreiheit
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>focus, blur, input</title>
</head>
<body>
<p>Wähle Farbe</p>
<input type="radio" name="colors" value="Rot" onchange="zeigeWahl()"/>Rot<br/>
<input type="radio" name="colors" value="Blau" onchange="zeigeWahl()"/>Blau<br/>
<p id="radio"></p>
</body>
</html>
JavaScript
function zeigeWahl() {
let x = document.getElementsByName("colors");
for (let i = 0; i < x.length; i++)
{
if (x[i].checked == true)
document.getElementById("radio").innerHTML += "Ausgewählt wurde: " + x[i].value + "<br/>";
}
}