0

I have several input check boxes that share a class called checkboxJobSeekerProfile. I am trying to write an alert that prints how many of them are checked. For some the alert always show 0 even when several of the check boxes are checked. Here is my alert

alert($('.checkboxJobSeekerProfile input[type=checkbox]:checked').length);

Here is my html

<label class="checkbox-inline"><input type="checkbox" class="checkboxJobSeekerProfile entry_level"
                                                  id="entry_level" value="entry_level">Entry-level</label>
            <label class="checkbox-inline"><input type="checkbox" class="checkboxJobSeekerProfile mid_level"
                                                  id="mid_level" value="mid_level">Mid-level</label>
            <label class="checkbox-inline"><input type="checkbox" class="checkboxJobSeekerProfile senior_level"
                                                  id="senior_level" value="senior_level">Senior-level</label>
            <label class="checkbox-inline"><input type="checkbox" class="checkboxJobSeekerProfile executive"
                                                  id="executive" value="executive">Executive</label>
Aaron
  • 4,380
  • 19
  • 85
  • 141

1 Answers1

0

You can select strictly by:

alert($('input[type=checkbox].checkboxJobSeekerProfile:checked').length);

JSFiddle Demo

Nick Tsai
  • 3,799
  • 33
  • 36