So I’m trying to set up a function that listens for IF AND ONLY IF 3 special items are “checked”.
So far I have a list with 9 items, and when the 3 “S” (for special) have the clicked class, the background will change blue, and then change back if any one of the 3 are un-clicked.
What I want to know is if there’s a way to make it so that the condition is met (blue background) IF AND ONLY IF the three “S” are checked and nothing else is checked.
See demo here: http://jsfiddle.net/stursby/V5Hee/
Any help would be great,
Thanks.
Yep, add a condition that make sure there are only 3 clicked, then check that they are the ones you want.
http://jsfiddle.net/V5Hee/2/
UPDATE
Using
.lengthrather than.size()as pointed out as better pracitce:http://jsfiddle.net/V5Hee/3/