On Mar 26, 9:13 am, J K <artlo...@gmail.com> wrote:
> I have a 65x65 HTML table, giving me 4225 TD cells.
> I am making each of them clickable with the following code:
> $('td').click(function () {
>   // do something
> });
> It works wonderfully in all browsers (well, IE is a little slow, but
> it's IE).

Event delegation is one approach and may work well for you. In some
cases it may not - for example, if you have click handlers on the rows
themselves that will cancel the event bubble.

Another strategy - one which I have used often - is to remove the
jQuery attaching of events and instead include an onclick="" attribute
in the source of each td. This is considerably faster in IE. Although
it's not "unobtrusive" in the magical jQuery sense, it won't hurt
anything (other than page file size), especially if this is for an
internal web app or something. As always, the compromise between
performance and other factors is something you have to consider
yourself.

Matt Kruse

Reply via email to