IsThatYou
IsThatYou

Reputation: 1

TweenMax does not animate (GSAP)

If I wrote the script code in my html file, the animation works. But if the animation code is in a js file, it just didn't work. here is my animation code

$(document).ready(function(){
    $(window).on("load", function() {
        var cow = document.getElementsByTagName("cow");

        TweenMax.to(cow, 2, {top:"1200px",ease: Back.easeOut});
}

)})

and here is what in the html file.

<!DOCTYPE html>
<html>
<head>

   <link rel = 'stylesheet' type = 'text/css' href = 'cow.css'/>
   <script src="http://code.jquery.com/jquery-2.0.3.min.js"></script> 
   <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/latest/TweenMax.min.js">       
   </script>

   <script type="text/javascript" src = 'showanimationcow.js'></script>

</head>
<body>
   <img id = "cow" src ="http://cdn.snappages.com/adwr7m/theme/338649/images/
   13179326871659847108SimpleCowArt.svg.hi_1393086508.png">
</body>

I will very much appreciate your help!

Upvotes: 0

Views: 1232

Answers (1)

Alan
Alan

Reputation: 188

You have to use document.getElementById("cow")

Also, it's not necessary to call $(document).ready and $(window).on("load",function() { the same time.

Upvotes: 1

Related Questions