>$("#toggle").click(function(){ > $("#calendar .arc").toggle(); > $("#calendar .arc").Highlight(1000, '#ff9'); > > var $this = $(this); > if($this.is ('.show')) > { > $this.removeClass('show'); > $this.addClass('hide').empty().append('Show archived members'); > var $ref = $("#calendar #navleft").attr("href"); > $("#calendar #navleft").attr("href", $ref.slice(0, -1)+'0'); > var $ref = $("#calendar #navright").attr("href"); > $("#calendar #navright").attr("href", $ref.slice(0, -1)+'0');
Remember to cache your selectors. There's definite overhead in creating instances of a jQuery object--so whenever possible you want to chain or cache your jQuery objects. For example: $("#calendar .arc").toggle(); $("#calendar .arc").Highlight(1000, '#ff9'); Could be re-written: $("#calendar .arc").toggle().Highlight(1000, '#ff9'); You can re-write: var $ref = $("#calendar #navleft").attr("href"); $("#calendar #navleft").attr("href", $ref.slice(0, -1)+'0'); As: var jCalNavLeft = $("#calendar #navleft"); var $ref = jCalNavLeft.attr("href"); jCalNavLeft.attr("href", $ref.slice(0, -1)+'0'); Also, since a document should contain only unique IDs for elements, there's no reason to use the selector: var jCalNavLeft = $("#calendar #navleft"); You can use: var jCalNavLeft = $("#navleft"); As there should be only one object with the unique ID of "navLeft" in your document. -Dan