<分区>
我在元素[比如<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/