根据我在这里找到的内容,我已经尝试了几个小时的不同方法,但无济于事。有人可以引导我朝着正确的方向前进吗?在检查或取消选中复选框时,我想丢弃确认书,然后根据用户选择,然后将复选框返回或取消选中。谢谢!
$('input:checkbox').click(function(){
var checked = $("input:checked").length;
if (checked == 0){
if(confirm('Are you sure you want to discontinue this program?')){
(':checkbox:checked').removeAttr('checked');
}
} else
{
if(confirm('Are you sure you want to resume use of this program?'))
(':checkbox:checked').attr('checked');
}
HTML
<table>
<tr>
<td><input name="input" type="checkbox" value="" /></td>
<td>Because We Care</td>
</tr>
<tr>
<td><input name="" type="checkbox" value="" /></td>
<td>Some Unused Program</td>
</tr>