how to select radio button in javascript code example
Example 1: html radio button checked
<input type="radio" id="huey" name="drone" value="huey"
checked>
Example 2: which radio button is selected javascript
$('#myForm input').on('change', function() {
alert($('input[name=radioName]:checked', '#myForm').val());
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<form id="myForm">
<input type="radio" name="radioName" value="1" /> 1 <br />
<input type="radio" name="radioName" value="2" /> 2 <br />
<input type="radio" name="radioName" value="3" /> 3 <br />
</form>
Example 3: javascript how to select radio button
function check() {
document.getElementById("red").checked = true;
}