Jquery help counting checked checkboxes
<p>I am trying to count the checkhed checkboxes. See her: <a href="http://jsfiddle.net/2bCdR/2/" rel="nofollow">http://jsfiddle.net/2bCdR/2/</a>
The Jquery counter does not work and does also deactive the other Jquery.</p>

<p>My Jquery {</p>

<pre><code>$.each($('div.category'), function () {
var categoryDiv = $(this);
function countChecked() {
  var n = $("categoryDiv input:checked").length;
  $("categoryDiv #counter").text(n);
}
}
countChecked();

$(":checkbox").click(countChecked);
</code></pre>

<p>My HTML</p>

<pre><code>&lt;form accept-charset="UTF-8" action="/" method="get"&gt;&lt;div style="margin:0;padding:0;display:inline"&gt;&lt;input name="utf8" type="hidden" value="&amp;#x2713;" /&gt;&lt;/div&gt;

        &lt;div class="menuitem category"&gt;
            &lt;label for="search_company1"&gt;company1&lt;/label&gt;
            &lt;input name="search[company1_is_true]" type="hidden" value="0" /&gt;
            &lt;input id="search_company1_is_true" name="search[company1_is_true]" type="checkbox" value="1" /&gt;
            &lt;div id="counter"&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="menuitem category"&gt;
            &lt;label for="search_company3"&gt;company3&lt;/label&gt;
            &lt;input name="search[company3_is_true]" type="hidden" value="0" /&gt;
            &lt;input id="search_company3_is_true" name="search[company3_is_true]" type="checkbox" value="1" /&gt;
            &lt;div id="counter"&gt;&lt;/div&gt;
        &lt;/div&gt;
        &lt;div class="hidediv"&gt;
            &lt;div class="menuitem"&gt;
                &lt;label for="search_company2"&gt;company2&lt;/label&gt;
                &lt;input name="search[company2_is_true]" type="hidden" value="0" /&gt;
                &lt;input id="search_company2_is_true" name="search[company2_is_true]" type="checkbox" value="1" /&gt;

            &lt;/div&gt;
        &lt;/div&gt;
        &lt;input id="search_submit" name="commit" style="display:none;" type="submit" value="Submit" /&gt;
&lt;/form&gt;
</code></pre>
