I have a checkbox with id myopt and I have a click event handler as below;
$("#globalBody").on("click", "#myopt", function (event) {
if ($(this).prop("checked")) {
// do something
} else {
// do something
}
});
Now in my code, I do
$("#myopt").attr("checked",true);
My question is this does not trigger the click event handler above. It gets called if I click the checkbox manually.
What is the issue ?