Thanks, Karl and Dave for your help on this.
I liked Dave's more compact code, this made me understand a little bit
more of how jQuery works, so I'm going with that for now.
Karl, I appreciate your reply as well, since speed might be a concern
in the near future. I'll keep that advice in mind al
*chuckle* As Dave has shown, sometimes it's good to rebuild code "from
scratch" rather than trying to optimise existing code (which is what I
did). Well done Dave.
Karl Rudd
On 10/11/07, Dave Methvin <[EMAIL PROTECTED]> wrote:
>
> > // save old active menu
> > var oldActive = $("#mainnav li.acti
> // save old active menu
> var oldActive = $("#mainnav li.active");
>
> // clear actives
> $("#mainnav li.active").removeClass("active");
>
> // activate current
> $("#mainnav li a").filter(function() {
> return isCurrent(this, 'href');
>
> }).parent().addClass("active");
>
> // re-activa
I haven't looked at the code you linked to but I've looked at the code
you posted. It's actually pretty compact, not to much room for
chaining.
The easiest "speed up" would be to "cache" your selectors, the
"mainnav" in particular:
var menu = $("#mainnav");
So this: $("#mainnav li.active")
4 matches
Mail list logo