Get rid of the anchor (it's not valid anyway), and you don't need to bind two click functions; your event delegation is fine--almost:
You need to wrap the event with $() to use the attr() method. $("#row33").click( function(e) { if( $(e.target).attr("id") == "innerX) { ; // do inner link things } else { ; // do outer click things } }); And use curly braces; just because JavaScript lets you get away with not using them, it's still better practice. On Mar 31, 3:06 pm, Blaine <bla...@worldweb.com> wrote: > Hey James, > > Your anchor tag for the table row is not needed. Simply add the id to > the table row. > > $( document ).ready( function(){ > > var allowClick = 1; > $("#row33").bind("click", function(e) { > if (allowClick){ > alert( "outer" ); > } > > }); > > $("#innerXX").bind( "click", function(e) { > alert( "inner" ); > allowClick = 0; > > }); > }); > > <table width="400"> > > <tr id="row33" bgcolor="#444444"> > <td> <a id="innerXX" href="#">inner link!</a> </td> > </tr> > </a> > </table> > > On Mar 31, 11:15 am, "james.kirin40" <james.kiri...@gmail.com> wrote: > > > Hi everyone! > > > A brief question from a newbie. I have a table row which I want to be > > clickable, but I have a specific link within one cell. Something like: > > > <a id="row33" href="#"> > > <tr> > > <td> <a id="innerXX" href="#">inner link!</a> </td> > > </tr> > > </a> > > > I want to have the clicks on the inner link call a certain function > > (eg, innerClick), while clicks on any other area of the row should > > call a different function (eg, outerClick). > > > I have tried binding a function to the click on the entire row, and > > then discriminating where the click happened inside the callback: > > > $("#row33").click( function(e) > > { > > if (e.target.attr("id") == "innerX) > > ; // do inner link things > > else > > ; // do outer click things > > > }); > > > The trouble is that the ".target" of the event passed to my callback > > does not have a attr() function; I get an error message "e.attr is not > > a function". What am I doing wrong? > > > I also tried assigning different classes to the row and to the inner > > link and discriminate based on .hasClass() with the same result. > > > If someone could offer me some very basic guidance on how to get > > information from event.target, that would be great. > > > Thank you so much for yoru help, > > > James