[jQuery] Re: toggle() animation - maybe there is a neater way to do this?

2008-03-08 Thread the_woodsman
Have you looked at JQ's built in toggle event? You won't have to keep track of even/odd clicks at all if you use that... On Mar 8, 8:53 am, Karl Swedberg <[EMAIL PROTECTED]> wrote: > Not sure if this is neater, but it does have fewer lines of code: > > var stoggle = false; > $("#button").click(f

[jQuery] Re: toggle() animation - maybe there is a neater way to do this?

2008-03-08 Thread Karl Swedberg
Not sure if this is neater, but it does have fewer lines of code: var stoggle = false; $("#button").click(function(){ var extra = 150, divTop = parseInt($('#div').css('top')); $('#div').animate({top: !stoggle ? divTop + extra : divTop - extra}, 400); stoggle = !stoggle; });