【发布时间】:2023-02-19 17:55:30
【问题描述】:
根据图像,我想选中和取消选中单选按钮,因为它们都存在和不存在。我写了一些代码,但它只工作一次。
$(document).on('click', '#btn_all_absent', function(e){
$("input:radio[class^=present]").each(function(i) {
$(this).attr('checked',false);
});
$("input:radio[class^=absent]").each(function(i) {
$(this).attr('checked',true);
});
});
$(document).on('click', '#btn_all_present', function(e){
$("input:radio[class^=absent]").each(function(i) {
$(this).attr('checked',false);
});
$("input:radio[class^=present]").each(function(i) {
$(this).attr('checked',true);
});
});
请建议我哪里错了。
【问题讨论】:
标签: javascript jquery