当用户单击复选框时,计数器#counter +1,这很好,但是当他取消选中时,对于同一个复选框,它不会 -1。当他们单击特定复选框和取消选中 -1 时,我想 +1。
--JS--
$('.CheckBox').toggle(function(){
$('#Counter').html('( '+i+' Selected )');
i++;
}, function() {
$('#Counter').html('( '+i+' Selected )');
i--;
});
---PHP---
do { ?>
<div style="position:relative; width:100%; height:20px; background-color:#FF5300;" class="CheckBox" id="<?php echo $row_EX['x1']; ?>">
<input type="checkbox" name="<?php echo $row_EX['x2']; ?>" value="<?php echo $row_EX['x3']; ?>" style="cursor:pointer; ">
<span style="position:relative; top:-2px; font-family:arial; color:#000; font-size:12px;"><?php echo $row_EX['lx4']; ?></span>
</div>
<div style="height:1px; width:1px;"></div>
<?php } while ($row_EX = mysql_fetch_assoc($EY)); ?>
<span style="position:relative; left:10px; top:6px; font-family:arial; font-size:16px;" id="counter">(0 Selected)</span>