在有规律的时间间隔内逐个跳出文本
Bounce Text one by one in regular interval of time
我正试图用文本编码一个弹跳效果,使其以规则的间隔一个接一个地弹跳,就像一个字幕。
我试过使用jquery,但没有让它一个接一个地反弹。
这是我的FIDDLE
。
js:
$(document).ready(function(){
$(".test").effect( "bounce",
{times:4}, 500 );
});
HTML:
<div class="test">
<p>First Time Bounce</p>
<p>This Bounce to nxt(After First)</p>
.
.
.
<p>Last Bounce Then return To First One</p>
</div>
如果更新HTML,使每个字母周围都有某种类型的包装元素,则可以依次为每个字母设置动画。然后你只需要循环浏览这些字母,并一次为它们设置一个动画。
$(document).ready(function(){
//setup a counter to keep our place and cache a selection to the letter wrappers
var counter = 0,
$chars = $(".test").children();
//setup an interval to animate a letter every so often
setInterval(function () {
//select the current letter wrapper and animate it
$chars.eq(counter).effect( "bounce", {times:1}, 500 );
//increment the counter so we animate the next letter next time around
counter++;
//check if the counter still relates to an index of the $chars collection
if (counter >= $chars.length) {
counter = 0;
}
}, 250);
});
这假设HTML结构如下:
<div class="test">
<span>s</span>
<span>o</span>
<span>m</span>
<span>e</span>
<span>t</span>
<span>e</span>
<span>x</span>
<span>t</span>
</div>
下面是一个演示:http://jsfiddle.net/jb9mt/6/
注意,当使用bounce
效果(ui-effects-wrapper
)来内联显示时,我必须更新添加到HTML结构中的jQueryUI包装元素的CSS:
.ui-effects-wrapper {
display : inline-block;
}
相关文章:
- Javascript,有没有一种方法可以将数组写成没有逗号或空格的单个文本字符串
- 是否有任何方法可以使用jQuery替换在数组中定义值的文本
- 如何检查链接是否有文本,并根据文本值评估条件-Jquery/JS
- 是否<asp:文本框>有一个onFocusLost事件
- 仅当变量有值时才显示D3文本标签
- 有没有办法将mouseOver上的个人文本添加到完整日历中
- 有没有一种方法可以从两个标签之间提取文本,并以我选择的格式输出
- 有人知道有没有jquery插件可以在图像上写文本,并让用户将其放置在图像内的任何位置
- 我能从“;输入“;事件是否有更好的方法来跟踪文本更改
- 有没有一种简单的方法可以将整数转换为等效文本.即:1变为1
- html表单,它有文本和表,现在我想在一个简单的文本文件中保存和检索数据,如何实现它
- 有CSS问题:can't将文本放置在选择框的右侧
- 选项设置文本值重复..有没有我可以检查的财产以避免重复
- 如果输入类型=文本有重复条目,如何更改其 CSS
- 在有规律的时间间隔内逐个跳出文本
- 文档选择中的索引错误,而所选文本有一个点
- 在Django中,用户输入不安全的文本有哪些危险?
- jQuery UI对话框文本有换行符选项吗?
- javascript/jquery,用数组中的随机文本有条件地替换文本
- 通过onload在画布上绘制文本时,文本有颗粒状/模糊