我有一个复选框ID为myopt,我有一个点击事件处理程序如下;Chekbox点击事件没有被触发检查
$("#globalBody").on("click", "#myopt", function (event) {
if ($(this).prop("checked")) {
// do something
} else {
// do something
}
});
现在在我的代码,我做
$("#myopt").attr("checked",true);
我的问题是不会触发上述点击事件处理程序。如果我手动点击复选框,它会被调用。
问题是什么?
使用变化而不是点击的任何理由? – testndtv
@testndtv,通过http://stackoverflow.com/questions/11205957/jquery-difference-between-change-and-click-event-of-checkbox – Satpal
哦,是的...和上面的代码实际上取消选中复选框! – testndtv