Inline events handlers are a whole different way of doing that. A bad and old one by the way.
The first approach you wrote, actually goes thru 2 iterations, while one is enough: $('div').click(function(){ alert('You clicked me: ' + this.id + '!') }); If you're REALLY worried about perfomance, you should google "event delegation". Cheers -- Ariel Flesler http://flesler.blogspot.com/ On 11 jun, 17:56, "Isaak Malik" <[EMAIL PROTECTED]> wrote: > Dear list, > > I'm not really into the code of the jQuery core so I'm not sure of how > jQuery.each() works, but I'm wondering: since jQuery.each() loops through > every element that matches the given selector is my logics right that is it > better performance wise to use static element event trigger instead of using > the each() method on all the elements? > > An example for the simple-minded: > > $('div').each(function(){$(this).click(function(){alert('You clicked me: ' + > this.id + '!')})}) > > or > > <div id='blabla1' onclick="alert('You clicked me: ' + this.id + '!')"></div> > <div id='blabla2' onclick="alert('You clicked me: ' + this.id + '!')"></div> > <div id='blabla3' onclick="alert('You clicked me: ' + this.id + '!')"></div> > > ? > > In most cases it does take more characters for the same functionality but > what are the differences in performance? > > Kind regards, > -- > Isaak Malik > Web Developer