JSFiddle - React, Tailwind, and code Playground

by dima_k

HTML

<fieldset>
    <legend>Which color do you prefer?</legend>
    <ul>
        <li>
            <input type="radio" value="red" name="color" id="colorRed" />
            <label for="colorRed">Red</label>
           </li>
        <li>
            <input type="radio" value="green" name="color" id="colorGreen" />
            <label for="colorGreen">Green</label>
        </li>
    </ul>
</fieldset>

JavaScript

var colors = document.getElementsByName('color');

for(var i = 0; i < colors.length; i++){
    alert(colors[i].value);
}