So I am working with a couple ascx with different checkbox areas on each control. I originally used
$('[type=checkbox]').click ( function(){ code });
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
$('#chck').click(function(){ code });
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?
I have also tried this:
$('#chck').each(function(){ $(this).click({ function() { code }); });
and this only worked for the first one as well
here is my ascx page example:
<asp:Repeater ID="contacts" runat="server">
<ItemTemplate>
<tr>
<td>
<input type="checkbox" id="chck" />
</td>
.....
</tr>
</ItemTemplate>
</asp:Repeater>
and here is my JS code segment
$(document).ready(function(){
$("#chck").each(function () {
$(this).click(function () { onchange($(this)); });
});
});
function onchange(checkbox) {
// adds contact to list
}