I rushed a bit in writing the html, the id should correspond to the table and not the tr. The is("button") didn't work but is("input") is getting what I wanted, thanks for the help.
On Apr 2, 5:55 pm, "Richard D. Worth" <rdwo...@gmail.com> wrote: > On Thu, Apr 2, 2009 at 4:14 PM, Thierry <lamthie...@gmail.com> wrote: > > > I have the following structure for tr: > > > <tr id="world"> > > <td></td> > > <td></td> > > <td> > > <input type="button" name="hello" value="hello" /> > > </td> > > </tr> > > > I also have the following javascript: > > > $("#world tr").click(function() { > > // do stuffs > > }); > > this selector doesn't seem to match your html, as it reads "all TRs within > the item with an id of world" but the item with an id of world is a TR, and > wouldn't contain any unless you've got nested tables. Perhaps you meant # > world.tr or <table id="world"><tr>? > > > > > Is there a way to prevent the above event from triggering when the > > hello button is clicked? > > check event.target inside the click callback > > $("#world").click(function(event) { > if (!$(event.target).is("button")) { > //do stuff > } > > }); > > - Richard