Jump to content
Search Community

String to ...

leander 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

Hello,

 

I´m new to Gsap so sorry for the Nub Question.

 

This works:

var acco1 = document.getElementById("mc_acco1");

dynTween(acco1);

function dynTween(element) {
    TweenLite.fromTo(element, 0.5, {opacity:0.5},{opacity:1.0, ease:Sine.easeInOut, onComplete:callTab});
}

This Not:

btnId = 1;
var mc_new = "acco"+ btnId;
dynTween(mc_new);

function dynTween(element) {
    TweenLite.fromTo(element, 0.5, {opacity:0.5}, {opacity:1.0, ease:Sine.easeInOut, onComplete:callTab});
}

But Why!? And how do I get to work!? Thx for your help :)

Link to comment
Share on other sites

Hi and welcome to forums,

 

In the first example you pass to the function DOM element, so it works. In the second example you pass a string. TweenLite have it's own small internal selector mechanism ( will pass the string to document.getElementById function ). So in the second example this will be the same as TweenLite.fromTo(document.getElementById("acco1"), 0.5, {opacity:0.5}, {opacity:1.0, ease:Sine.easeInOut, onComplete:callTab});

 

The problem I think is that the element with such an ID doesn't exists. 

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...