JSFiddle - React, Tailwind, and code Playground

by tr_santi

HTML

1 <input type="radio" name="a" value="1" checked><br>
2 <input type="radio" name="a" value="2"><br>
3 <input type="radio" name="a" value="3"><br>
4 <input type="radio" name="a" value="4"><br>
5 <input type="radio" name="a" value="5"><br>
6 <input type="radio" name="a" value="6"><br>

<button>Which is checked?</button>

JavaScript

$("button").click(function() {
	var answer = $("input[type=radio]:checked").first().val();
    alert(answer);
})