[jQuery] click
[jQuery] click
I am having an odd behavior when calling click() on a checkbox [2] vs
manually checking a checkbox [1].
function checkbox_click(event)
{
event.stopPropagation();
do_email(enable_email.url);
if($(event.target).attr('checked'))
{
$(event.target).parent().parent().find("td").addClass('selected');
}
else
{
$(event.target).parent().parent().find("td").removeClass();
}
}
1. $('#sortable_table tbody :checkbox').click(checkbox_click);
2. $("#sortable_table tbody tr").click(function(event)
{
$(this).find(":checkbox").click();
});
#1 calls the function checkbox_click when a checkbox inside a table is
clicked. Is a checkbox is checked after the click occurs,$
(event.target).attr('checked') is TRUE.
#2 is called when a row in the table is clicked. It then finds the
checkbox inside the row and clicks it. This causes checkbox_click to
be fired, but ,$(event.target).attr('checked') is FALSE.
How can I get the same result from each function?