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});
啊我終於明白了。我錯過了jQuery的顯示句柄$(function(){}); – user2903934