Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
cerulean

Tweening Multiple Objects from jQuery

Recommended Posts

UPDATE: Arggh. I am tired. Pesky quotation marks!

 

I may be just tired today, but this is throwing me -- I'm getting a syntax error on the following line. I'm trying to tween multiple objects returned by jQuery to 0px (this is the ubiquitous accordion menu — I'm trying to replace jQuery slideUp and slideToggle with GSAP equivalents)

 

 TweenMax.to($('#nav li ul'),0.25,{css:{height:0px}});

 

Can GS parse the return of a jQuery selector that returns multiple values? I had thought so --

 

I'm probably missing a parenthesis, and I apologize if I am, but I don't see it!

Link to post
Share on other sites

Absolutely - GSAP can handle a jQuery object with multiple results. No problem. The issue with your code is that you're defining 0px instead of "0px". Without the surrounding quotes, Javascript is literally trying to evaluate 0px as if it's a variable or something, but variable names can't start with numbers, so it just gets utterly confused. If it was just 0, that'd be fine. But putting the "px" afterwards prevents it from being a number or a valid variable.

 

So either do height:"0px" or height:0.

 

:)

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×