Eg. $('td').bind('click', function(e){ if(e.target===this){ cb = $(this).children(':checkbox').trigger('click'); return false; } });
On May 15, 4:16 pm, "Richard D. Worth" <[EMAIL PROTECTED]> wrote: > The click callback gets the event object as the first parameter. Check the > event.target property. That will be the DOMElement actually clicked on. In > your case, simply make sure it's a TD (ignoring the click on the checkbox, > as that one's handled by the browser default). > > - Richard > > On Thu, May 15, 2008 at 10:36 AM, Andiih <[EMAIL PROTECTED]> wrote: > > > Hi > > > I have some checkboxes in table cells. I would like a click anywhere > > in the td to trigger the toggle of the checkbox. > > > I thought something like this would do it (obviously with more > > specific selectors for the real world) > > > $("td").click(function(){ > > $(this).children("input").each(function(){ > > if (this.checked) { $(this).attr('checked',''); } > > else { $(this).attr('checked','true'); } > > }); > > }); > > > this works for a click on the table cell, but stops the action of > > clicking on the checkbox itself from working - presumably because its > > running the above plus the standard HTML toggle, and therefore > > canceling itself out. Any ideas ?