我正在尝试使用Greensock文本插件。我可以改变文字的颜色,但我不能改变文字。我正在使用jQuery 3.2.1和Greensock TweenMax 1.20.3
我的代码会将文字颜色更改为白色,但文字将保留为Test
。我也没有收到任何控制台错误。
var myElement = $("#scramble");
TweenLite.to(myElement, 2, {
text: "This is the new text",
color: "#FFFFFF",
ease: Linear.easeNone,
paused: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<div id="scramble">Test</div>
答案 0 :(得分:4)
您需要添加Greensock TweenMax Text插件。
var myElement = $("#scramble");
TweenLite.to(myElement, 2, {
text: "This is the new text",
color: "red",
ease: Linear.easeNone,
paused: false
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/TweenMax.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/1.20.3/plugins/TextPlugin.min.js"></script>
<div id="scramble">Test</div>