Example
HTML
html
<form>
<label><input type="radio" name="color" value="blue" />Blue</label>
<label><input type="radio" name="color" value="red" />Red</label>
</form>
JavaScript
js
// Get the form
const form = document.forms[0];
// Get the form's radio buttons
const radios = form.elements["color"];
// Choose the "red" option
radios.value = "red";
Result
Specifications
| Specification |
|---|
| HTML # dom-radionodelist-value |
Browser compatibility
See also
- The
<form>,<fieldset>,<input>elements.