2014-04-02 43 views
1

我是Tweenmax动画的新手,我试图给id选择器设置动画效果,不幸的是没有任何事情发生。选择器和内容都无所作为。有人帮助我,这里是代码。GreenSocks Tweenmax动画

<!DOCTYPE html> 
<html> 
    <head> 
     <title>my first tween</title> 

     <style> 
      body { 
       background-color:silver; 
      } 

      #sample { 
       width: 402px; 
       height: 60px; 
       background-color:teal; 
       padding: 8px; 
      } 
     </style>  

     <script type="text/javascript" src="jquery.gsap.js"></script> 
     <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script> 
     <script src="http://cdnjs.cloudflare.com/ajax/libs/gsap/1.11.6/TweenMax.min.js">/script> 
    </head> 

    <body> 
     <div id="sample"> 
      <!-- Some content --> 
     </div> 
    </body> 
</html> 

这里是JS

var drew = document.getElementById("sample"); //or use jQuery's $("#sample") 
TweenLite.to(sample, 1.5, {width:100}); 
+0

啊我终于明白了。我错过了jQuery的显示句柄$(function(){}); – user2903934

回答

1
<script> 
    $(function(){ 
     TweenLite.to($("#sample"), 1.5, {width:100}); 
    }); 
</script> 
0

使用

var drew = document.getElementById("sample"); //or use jQuery's $("#sample") 
    TweenLite.to(drew , 1.5, {width:100}); 

你把样品,而不是德鲁。