radio button selected value code example

Example 1: get radio button value javascript

document.querySelector('input[name="rate"]:checked').value;

Example 2: html radio button checked

<input type="radio" id="huey" name="drone" value="huey"
         checked> 
<!-- https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/radio-->

Example 3: radio button group get value javascript

$('input[name=gender]:checked').val();

Example 4: javascript on click radio button get value

if (document.getElementById('r1').checked) {
  rate_value = document.getElementById('r1').value;
}

Tags:

Html Example