jQuery incrementally count selected checkbox and deselected checkbox
<p>I have an ASP.NET web form that has 6 checkbox. 1 checkbox is to call a Function to select all checkbox and show the message "You have selected" 6 "items" (in this case, 6 checkbox). If a user doesn't select the Select All checkbox, they can select or deselect other checkbox individually and the message will be "You have selected" # "items" I'm trying to do this in jQuery, but it's not working yet. Here's the script:</p>

<pre><code>    &lt;script  type="text/javascript"&gt;
    //This function works on the click event of SelectAll checkbox
    function selectAll(involker) {
        $('input:checkbox').attr('checked', $(involker).attr('checked'));

        var count = $(":checkbox:checked").length;
        $("#selectedCheckboxMessage").html(count).css({ 'background-color': '#228B22', 'font-weight': 'bolder', 'color': '#FFFFFF', 'padding-left': '0.5em', 'padding-right': '0.5em' });

    }

    //Not working, the message wont's show up on the click event of the checkbox
    $(function() {

        $("input[id ^= ctl00_ContentPlaceHolder1_dlTimeSheet_ctl]").click(showCheckboxStatus);

    });

    function showCheckboxStatus(evt) {

        var numSelected = $(":checkbox:checked").length;
        $("#selectedCheckboxMessage").html("You have selected " + numSelected).css({ 'background-color': '#228B22', 'font-weight': 'bolder', 'color': '#FFFFFF', 'padding-left': '0.5em', 'padding-right': '0.5em' });

    }
</code></pre>

<p></p>

<p>The message shows only when a SelectAll checkbox is selected. The message doesn't show if other checkbox is selected or deselected.</p>

<p>I look for an checkbox Id $("input[id ^= ctl00_ContentPlaceHolder1_dlTimeSheet_ctl]") instead of looking for a CSS class. On the markup </p>

<pre><code>&lt;asp:CheckBox ID="cbMarkAsComplete" runat="server" CssClass ="CheckBoxClass"   /&gt;
</code></pre>

<p>will make the following HTML output:</p>

<pre><code>&lt;span class="CheckBoxClass"&gt;&lt;input type="checkbox" name="ctl00$ContentPlaceHolder1$dlTimeSheet$ctl00$cbMarkAsComplete" id="ctl00_ContentPlaceHolder1_dlTimeSheet_ctl00_cbMarkAsComplete"&gt;&lt;/span&gt;
</code></pre>

<p>The CSS class CheckBoxClass is not with the HTML input, that's why I'm looking for checkbox  Id instead of checkbox class.</p>

<p>Thank you for the input.</p>
