【发布时间】:2011-12-05 21:33:57
【问题描述】:
(jQuery 1.4.4) 我有一个复选框,它有一个 .change() 监听器,当用户单击复选框时它工作得很好,但现在当我以编程方式更改 jQuery 中的复选框时,我还需要它来触发,使用.attr('检查','检查')。我很高兴使用其他方法来完成这项工作。谢谢。
$('#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
}
【问题讨论】:
标签: jquery