Select and trigger click event of a radio button in jquery
My solution is a bit different:
$( 'input[name="your_radio_input_name"]:radio:first' ).click();
You are triggering the event before the event is even bound.
Just move the triggering
of the event to after attaching the event.
$(document).ready(function() {
$("#checkbox_div input:radio").click(function() {
alert("clicked");
});
$("input:radio:first").prop("checked", true).trigger("click");
});
Check Fiddle
$("#radio1").attr('checked', true).trigger('click');
Switch the order of the code: You're calling the click event before it is attached.
$(document).ready(function() {
$("#checkbox_div input:radio").click(function() {
alert("clicked");
});
$("input:radio:first").prop("checked", true).trigger("click");
});