[thelist] change active td with children elements

Joshua Olson joshua at waetech.com
Fri Aug 29 13:26:43 CDT 2003

----- Original Message ----- 
From: "shortestpath" <shortestpath at yahoo.com>
Sent: Friday, August 29, 2003 1:24 PM

> I have a table cell which when clicked on, I change its
> borders:
> <snip>
> The problem is that the cell contains a div, which contains
> an image:
> <td><div><img ...></div></td>
> If the div or img get clicked on instead of the td itself,
> the borders don't change. How can I make it so that if the
> div or img inside the td gets clicked on, the border changes?


Forgo using CSS, and instead us JS.

Events propagate upward towards the document root from the element being
clicked upon.  Therefore, if you apply code to the onclick handler of the
td, then any clicks on the div and img will eventually fire the event at the
td.  Make sure you pass "this" to the function within the onclick handler so
that you'll get an immediate reference to the td.


Joshua Olson
Web Application Engineer
WAE Tech Inc.

More information about the thelist mailing list