RadioNodeList: value property
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 in
checked
state, the empty string is returned. On setting the
value
property, the first radio button input element whose
value
property is equal to the new value will be set to
checked
.
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
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
value |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
See also
- The
<form>
,<fieldset>
,<input>
elements.