添加文本框并使用旋转字符串进行动画处理
Add text box and animate using rotating string
嗨,我们的老师要求我们添加输入类型="文本",并使用带有以下代码的旋转字符串对其进行动画处理:
<html>
<head>
<title>Javascript Basic Animation</title>
<script type="text/javascript">
function animate_string(id)
{
var element = document.getElementById(id);
var textNode = element.childNodes[0]; // assuming no other children
var text = textNode.data;
setInterval (function ()
{
text = text[text.length - 1] + text.substring (0, text.length - 1);
textNode.data = text;
}, 100);
}
</script>
</head>
<body onload="animate_string('target')">
<pre>
Write a Javascript program to rotate the string 'HELLO WORLD'
in right direction by periodically removing one letter from
the end of the string and attaching it to the front.
</pre>
<font size="21">
<pre id="target">HELLO WORLD</pre>
</font>
</body>
</html>
但我不知道怎么做。请帮忙谢谢:)
试试这个:
s = "hello world" ;
l = strlen(s) ;
tmp = substr(s, 1, l-2) + substr(s, 0, 1) ;
s = tmp
你只需要从脚本调用animate_string('这里的元素 id');
相关文章:
- 如何设置html元素填充的动画
- 如何在JavaScript中将字符串转换为函数引用
- 如何使用动画实现纸张推车
- 如何在生成下载文件时显示加载动画
- 剑道网格jQuery动画()问题
- EaseJS拖放;放下(动画CC)电影剪辑的鼠标坐标
- jQuery中是否内置了任何字符串格式化函数
- jQuery Lazy加载动画滚动
- jquery动画可以通过编程链接吗
- Javascript将数学动画化
- 动画.CSS重播
- Javascript,有没有一种方法可以将数组写成没有逗号或空格的单个文本字符串
- ng打开空字符串
- 制作一个不带HTML a标记但在动画播放完毕后指向其他页面的超链接
- 绘制动画openlayers线条字符串路径
- 尝试制作带有动画的随机字符串生成器
- 添加文本框并使用旋转字符串进行动画处理
- 基于页面加载匹配字符串的Jquery动画
- 如何";动画"/在java脚本中隐藏然后取消隐藏字符串
- 改变Java脚本中动画字符串的位置