你如何在每秒钟更改文字? [英] how do you make text change every __ second?

查看:99
本文介绍了你如何在每秒钟更改文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个网站: http://www.twosides.co/ 在其主页上,如果你看看它几秒钟,文本不断变化,一个非常酷的效果。任何人都有想法做到这一点?

我完全没有线索,所以我来到了stackoverflow社区寻求帮助!



感谢所有回答问题的人! 解决方案

更改消息:

 < script src =http://code.jquery.com/jquery-1.7.min。 JS>< /脚本> 
< script>
$(function(){
var messages = [],
index = 0;

messages.push('Message 1');
messages.push('Message 2');
messages.push('Message 3');

function cycle(){
$('#some-id') .html(messages [index]);
index ++;

if(index === messages.length){
index = 0;
}

setTimeout(cycle,3000);
}

cycle();
});
< / script>
< div id =some-id>< / div>

只需添加一些动画代码即可。


This website: http://www.twosides.co/ on its main page if you look at it for a couple of seconds, the text keeps on changing with a really cool effect. Anyone have an idea to do this?

I have absolutely no clue how to, so i have come to the stackoverflow community for help!

Thanks to everyone who answers!

解决方案

Something like this will change the message:

<script src="http://code.jquery.com/jquery-1.7.min.js"></script>
<script>
$(function () {
    var messages = [],
        index = 0;

    messages.push('Message 1');
    messages.push('Message 2');
    messages.push('Message 3');

    function cycle() {
        $('#some-id').html(messages[index]);
        index++;

        if (index === messages.length) {
            index = 0;
        }

        setTimeout(cycle, 3000);
    }

    cycle();
});
</script>
<div id="some-id"></div>

Just add some animation code.

这篇关于你如何在每秒钟更改文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆