Reputation: 1169
I would like to create an alert once too many check boxes have been checked.
Please see the setup here:
At the moment - the alert keep returning 0 - rather than counting the checkboxes...
Any suggestions would be great thanks!
Upvotes: 0
Views: 83
Reputation: 65126
You need to put the length calculation inside the event handler, otherwise it's just going to be calculated once in the start and be 0 constantly.
Upvotes: 1
Reputation: 84140
http://jsfiddle.net/wDbej/6/ - move your variable inside the click function. The way you had it initialized the variable, but didn't update the value on clicking the box.
Upvotes: 1