JSFiddle - React, Tailwind, and code Playground

by Nathan Friend

HTML

<div id='container'>
    <input type="radio" name="test" value="1"> Option 1<br />
    <input type="radio" name="test" value="2"> Option 2<br />
    <input type="radio" name="test" value="3"> Option 3<br />
    <input type="radio" name="test" value="4"> Option 4<br />
    <input type="radio" name="test" value="5"> Option 5<br />
</div>

CSS

#container {
    margin: 20px;   
}

JavaScript

$(function() {
    $('[name="test"]').each(function() {
        $(this).click(function(e) {
            e.preventDefault();
            if ($(this).is(':checked')) {
                alert('This radio button was checked');
            } else {
                alert('This radio button was not checked');
            }                    
        });
    });           
});