RadioNodeList: value property - Web APIs | MDN (original) (raw)

If the underlying element collection contains radio buttons, the**RadioNodeList.value** property represents the checked radio button. On retrieving the value property, the value of the currently checked radio button is returned as a string. If the collection does not contain any radio buttons or none of the radio buttons in the collection is inchecked state, the empty string is returned. On setting thevalue property, the first radio button input element whosevalue property is equal to the new value will be set tochecked.

Syntax

value = radioNodeList.value
radioNodeList.value = string

Example

HTML

<form>
  <label><input type="radio" name="color" value="blue" />Blue</label>
  <label><input type="radio" name="color" value="red" />Red</label>
</form>

JavaScript

// 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 Standard # dom-radionodelist-value

Browser compatibility

BCD tables only load in the browser

See also