JSFiddle - React, Tailwind, and code Playground
HTML
<input id="rb1" type="radio" name="rb" value="one" checked="true" />
<input id="rb2" type="radio" name="rb" value="two" />
JavaScript
$("#rb2").change(function () {
if ($(this).is(":checked")) {
console.warn('checked');
} else {
console.warn('unchecked');
}
});
$("input[type=radio]").on("change", function (e) {
var $this = $(this);
//all inputs with the same name
var $targetInputSelector = $("input[name=" + $this.attr("name") + "]");
//console.info($this);
//console.info($(targetInputSelector));
//console.warn($(targetInputSelector).not($this));
//check if the handler was fired "naturally"
//if yes, trigger the change handler "artificially" for inputs with the same name
if (e.hasOwnProperty('originalEvent')) {
//exclude the element that was changed "naturally"
//from the subset of all the elements with the same name
$targetInputSelector.not($this).triggerHandler("change");
}
});