JSFiddle - React, Tailwind, and code Playground

HTML

<script>  
    function myFunction()
            {              
                if(document.getElementById('a1').checked)
                {
                     alert("in if")
                    var x = document.getElementById('a1').value
                    alert(x);
                }else
                {
                    alert("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
                }

            }</script>

<p> How much is 2+2 ?? </p>
<input type="radio" name="ans" id="a1" value="4"/><br/ >
<input type="radio" name="ans" id="a2" value="5"/><br/ >
<input type="radio" name="ans" id="a3" value="6"/><br/ >
<input type="radio" name="ans" id="a4" value="7"/><br/ >

 <button onclick="myFunction()">Click me</button>