Matt Kruse wrote: > 1) There seems to be a lot of emphasis on using selectors and > pseudo-selectors to access everything. It makes code short and simple, but > is it really the most efficient?
Reusing selectors helps performance. You can reuse a selection by storing selected elements in a variable, like this: var $p = $('p'); You can then run as many operations as you like on $p, without any more selections. Most of the time, you can take it a step further, and hang onto selections across multiple elements/function invocations using closures: $(document).ready(function(){ var $p = $('p'); $('a').bind('click', function(){ $p.doSomething(); }); }); This way, unless the dom changes, you only have to make the selection once. :-) Luke _______________________________________________ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/