JSFiddle - React, Tailwind, and code Playground
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).mousedown(function(e) {
e.preventDefault();
if ($(this).is(':checked')) {
alert('This radio button was checked in mousedown');
} else {
alert('This radio button was not checked in mousedown');
}
});
$(this).click(function(e) {
e.preventDefault();
if ($(this).is(':checked')) {
alert('This radio button was checked');
} else {
alert('This radio button was not checked');
}
});
});
});