我一直在嘗試根據我在這裏發現的不同的方法幾個小時,無濟於事。有人可以引導我走向正確的方向嗎?當選中或取消選中複選框時,我想輸入確認信息,然後使複選框根據用戶選擇返回選中或取消選中。謝謝!確認框後檢查複選框
$('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>
請之前發佈您的問題http://stackoverflow.com/questions/5944889/intercepting-checkbox-click-to-confirm-the-change正確谷歌 – 2012-08-06 16:38:44