Reputation: 9289
In my MVC page i am generating a group of check boxes. Every check box have sameclass called 'resultTableCheckBox'
I want to get number of selected checkboxes .I tried following code
$(".resultTableCheckBox").live('click', function (event) {
alert($(".resultTableCheckBox :checked").length);
});
But above code always alert 0. I tried
$(".resultTableCheckBox").live('click', function (event) {
alert($(".resultTableCheckBox ").length);
});
Now its alert the total number of checkboxes having same class resultTableCheckBox. But how can i get number of selected check boxes
Upvotes: 2
Views: 982
Reputation: 58
The :checked selected should not have a space. Tested it and it works.
$(".resultTableCheckBox:checked")
Upvotes: 1
Reputation: 14827
Your selector is finding all children of all .resultTableCheckBox
elements that are checked. You need to add the ":checked" selector directly to the class.
$(".resultTableCheckBox:checked")
Upvotes: 5