How do I access the RadioNodeList interface on a Fieldset

Viewed 26

According to the documentation

"The RadioNodeList interface represents a collection of radio elements in a form or a fieldset element."

But in the example on the value property a form element is used.

I have not been able to figure out how to access the interface on a fieldset.

Attempt on codepen

HTML:

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


<fieldset id="radioNodeList_fieldset">
  <label><input type="radio" name="color_" value="blue">Blue</label>
  <label><input type="radio" name="color_" value="red">Red</label>
</fieldset>

JS:

const form = document.getElementById('radioNodeList_form');

let radios = form.elements['color'];

console.log(radios);

radios.value = 'red';


const fieldset = document.getElementById('radioNodeList_fieldset');

radios = fieldset.querySelectorAll('input');

console.log(radios);

Help would be appreciated. Thx ;)

0 Answers
Related