MDN Web Docs

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

Help improve MDN

Yes No

Learn how to contribute

This page was last modified on by MDN contributors.

Read the original on developer.mozilla.org ↗