(jQuery 1.4.4)我有一个复选框,它有一个.change()监听器,当用户单击复选框时能正常工作,但现在我也需要在使用jQuery以编程方式更改复选框时触发它,使用.attr('checked','checked')。我很乐意使用其他方法使其工作。谢谢。
$('#foo').attr('checked', 'checked'); // programmatically change the checkbox to checked, this checks the box alright
$('#foo').change( function() {
// this works when user checks the box but not when the above code runs
}