我在元素 [like] 中创建了一些假复选框<span>
(在真正的复选框之后)它们工作正常!我想要的是,当一个复选框被点击(选中)时,我如何计算选中的复选框;
我知道一些方法,比如:
$(".elm:checked").length;
但它不能正常工作!
我有以下代码用于计算选中的复选框,例如:
$(document).ready(function(){
$(".mycheckbox").click(function(){
$(".checkbox").click(function(){
alert($(".checkbox:checked").length)); // returns : if check box is checking return 0, if remove checked it returns 1 , its incorrect ! should be if checking return 1 else return 0
});
});
}
而且我知道它是因为我的假复选框,当用户单击假复选框时,jquery 中的一个新功能将单击真正的复选框,然后它就可以正常工作了!
任何人 ?任何想法!?
[对不起,我的英语很差]
jsfiddle:http: //jsfiddle.net/E2kjM/2/