Jump to content
Search Community

Tweening Multiple Objects from jQuery

cerulean test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

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 comment
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 comment
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.
  • Create New...