sle*_*cow 1 javascript jquery svg jquery-animate velocity.js
我刚刚开始使用Velocity.js,并尝试制作一个简单的动画,在该动画中我将圆圈的颜色从红色更改为黄色。我拥有的HTML只是...
<!DOCTYPE html>
<html>
<head>
<link href="https://code.jquery.com/ui/1.9.2/themes/smoothness/jquery-ui.css" rel="stylesheet" type="text/css" />
<script src="https://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="https://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script src="https://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="//cdn.jsdelivr.net/velocity/1.2.2/velocity.min.js"></script>
<script src="//cdn.jsdelivr.net/velocity/1.2.2/velocity.ui.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<svg height=300 width=300>
<circle id="example" cx=50 cy=50 r=20 fill="red"></circle>
</svg>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
...并且我试图像这样在我的JavaScript中将圆圈的颜色更改为黄色:
$('#example')
.delay(1000)
.velocity({fill: "yellow"});
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
根据Velocity.js文档,您需要将填充颜色值作为十六进制字符串传递:
片段:
$('#example').delay(1000).velocity({ fill: '#ffff00' }, { duration: 2000 });Run Code Online (Sandbox Code Playgroud)
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/velocity/1.2.2/velocity.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/velocity/1.2.2/velocity.ui.min.js"></script>
<svg height=300 width=300>
<circle id="example" cx=50 cy=50 r=20 fill="red"></circle>
</svg>Run Code Online (Sandbox Code Playgroud)
希望这可以帮助。
PS您正在尝试加载多个jQuery版本,即1.8.3和1.9.1。删除不必要的一个。
| 归档时间: |
|
| 查看次数: |
2384 次 |
| 最近记录: |