Thanks guys for the pointer. I had never actually heard of event delegation before. Every day is a school day. So, I read the article and I was keen to implement it to try and solve my problem. But I think I have a couple of conceptual leaps I need help with.
For my row highlighting to work, I need two events (mouseover and mouseout), so I thinking I am still going to need two functions? So I had a go at the mouseover one (see below), but it did not work. You guys who have a little more experience of this than me, can you see what I am doing wrong? >From this: $(".row").mouseover(function() { $(this).addClass("row_highlight"); }); To this: $('div.datarows').mouseover(function(event) { var $thisRow, $tgt = $(event.target); if ($tgt.is('div.row')) { $thisCell = $tgt; } else if ($tgt.parents('div.row').length) { $thisCell = $tgt.parents('div.row:first'); } // now do something with $thisCell $thisCell.addClass("row_highlight"); }); Thanks in advance, Stephen On Dec 16, 12:43 pm, Mike Alsup <mal...@gmail.com> wrote: > > You should have a look at event delegation, currently you are attaching 2 > > event on each row. So if you have a lot of rows, its memory/cpu heavy. > > I agree with Olivier. Here's a resource to get you started: > > http://www.learningjquery.com/2008/03/working-with-events-part-1