Dynamically adding click event to checkbox, only works for first checkbox JQUERY
<p>So I am working with a couple ascx with different checkbox areas on each control.
I originally used </p>

<pre><code> $('[type=checkbox]').click ( function(){ code });
</code></pre>

<p>and it did the job, At first. But when i added another control, also using checkboxes, the function was firing for the other checkboxes as well so i upgraded the js to</p>

<pre><code> $('#chck').click(function(){ code });
</code></pre>

<p>But with this, it only fires an event for the first checkbox in that list.. how can i get it to fire for all clicks?</p>

<p>I have also tried this:</p>

<pre><code> $('#chck').each(function(){ $(this).click({ function() { code }); });
</code></pre>

<p>and this only worked for the first one as well</p>

<p>here is my ascx page example:</p>

<pre><code> &lt;asp:Repeater ID="contacts" runat="server"&gt;
            &lt;ItemTemplate&gt;
                &lt;tr&gt;
                    &lt;td&gt;
                        &lt;input type="checkbox" id="chck" /&gt;
                    &lt;/td&gt;
                  .....
                 &lt;/tr&gt;
             &lt;/ItemTemplate&gt;
  &lt;/asp:Repeater&gt;
</code></pre>

<p>and here is my JS code segment</p>

<pre><code>    $(document).ready(function(){
       $("#chck").each(function () {
           $(this).click(function () { onchange($(this)); });
       });
    });
    function onchange(checkbox) {
    // adds contact to list
    }
</code></pre>
