On Feb 25, 3:23 pm, MeanStudios <cody.lundqu...@gmail.com> wrote: > If someone could just give me some good pointers so I can put them > into practice, that would be great :).
I'm just going to point out one thing that I also try to hammer into the heads of new jQuery developers I work with - cache references to jQuery objects in temporary variables! > target = $(this).attr("target"); > $(this).removeClass("selected"); > $(target).parent().animate({'opacity' : '0'}, 500, function(){ > $(target).parent().animate({'height' : "0"}, 500, function(){ > $(target).parent().prev().prev().prev().css({'border-bottom' : '0'}); > $(target).parent().removeClass("open"); In this example, you could do: var $this = $(this); var $target_parent = $($this.attr("target")).parent(); $this.removeClass("selected"); $target_parent.animate({'opacity' : '0'}, 500, function(){ $target_parent.animate({'height' : "0"}, 500, function(){ $target_parent.prev().prev().prev().css({'border-bottom' : '0'}); $target_parent.removeClass("open"); Similarly, > $(target).css({'position' : 'relative'}); > $(target).parent().addClass("open"); > $(target).fadeOut(10, function(){ should be: var $target = $(target); $target.css({'position' : 'relative'}); $target.parent().addClass("open"); $target.fadeOut(10, function(){ Every time you do $() you are calling a function and creating a new object, which actually has some overhead. Only jQuery-ize an object once, and then refer back to that jQuery object repeatedly. Matt Kruse