JSFiddle - React, Tailwind, and code Playground

by dmethvin

HTML

<input type="radio" name="foo" value="1" />
<input type="radio" name="foo" value="2" />
<input type="radio" name="foo" value="3" />
<input type="radio" name="foo" value="4" />

JavaScript

var n = document.getElementsByName("foo");
for ( var i=0; i < n.length; i++ ) {
    n[i].onclick = function(e){
        e.preventDefault();
        console.log("clicked "+e.target.value);
    };
}