counting the number of checkboxes checked
<p>I have some HTML like this: </p>

<pre><code>&lt;div id="SomeID"&gt;
 &lt;div class="Wrapper"&gt;
    &lt;input type="checkbox" class="SomeCheckboxClass"&gt;
    &lt;input type="checkbox" class="SomeCheckboxClass"&gt;
    &lt;input type="checkbox" class="SomeCheckboxClass"&gt;
 &lt;/div&gt;

 &lt;div class="Wrapper"&gt;
    &lt;input type="checkbox" class="SomeCheckboxClass"&gt;
    &lt;input type="checkbox" class="SomeCheckboxClass"&gt;
    &lt;input type="checkbox" class="SomeCheckboxClass"&gt;
 &lt;/div&gt;
&lt;/div&gt;
</code></pre>

<p>When the user clicks on a checkbox, I want to clear all the neighboring checkboxes in the parent Wrapper div. Basically, I only want one SomeCheckboxClass per Wrapper selected at any given time. For now, I wrote this:</p>

<pre><code>$('#SomeID').on({

   change: function () {

        if ($(this).attr('checked') === 'checked') {

        var TheIndex = $(this).index();

        $(this).parent().find('.SomeCheckboxClass').each(function () {

            if ($(this).index() !== TheIndex) {
                $(this).attr('checked', false);
            }
        });
      }
   }
}, '.SomeCheckboxClass');
</code></pre>

<p>Is there an easier way to do it? After spending some time doing it I'm thinking there's got to be an easier way. Note that the HTML is generated at runtime. Let me know if there's easierr/better/faster.</p>

<p>Thanks.</p>
