Upon document load, am trying to trigger the click event of the first radio button.... but the click event is not triggered
.Also, tried 'change' instead of click ...but its the same result.
$(document).ready(function() { //$("#checkbox_div input:radio").click(function() { $("input:radio:first").prop("checked", true).trigger("click"); //}); $("#checkbox_div input:radio").click(function() { alert("clicked"); }); });
Please follow the below link to the question
Example: http://jsbin.com/ezesaw/1/edit
Please help me out in getting this right. Thanks!
Responding to Click Events When the user selects one of the radio buttons, the corresponding RadioButton object receives an on-click event. To define the click event handler for a button, add the android:onClick attribute to the <RadioButton> element in your XML layout.
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
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"); });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With