javascript - 一定时间后重新加载特定的 div

标签 javascript jquery html css

我目前正在为客户测试 Twitter 墙,当页面以 javascript 开头时我正在加载墙。是否可以在不重新加载浏览器的情况下重新加载 div 或 javascript?

这是我的div

<div id="social-stream"></div>

用js加载

$(document).ready(function($){
$('#social-stream').dcSocialStream({
    feeds: {
        twitter: {
            id: '#%23hashtag',
            thumb: true,
            images:'medium',
        },

    },
    rotate: {
        delay: 0
    },
    twitterId: 'something',
    control: false,
    filter: false,
    wall: true,
    cache: false,
    max: 'limit',
    limit: 16,
    });
});

最佳答案

是的,您可以使用 setInterval喜欢,

$(document).ready(function ($) {
    function socialStream() {
        $('#social-stream').html('').dcSocialStream({
            feeds: {
                twitter: {
                    id: '#%23swiss',
                    thumb: true,
                    images: 'medium',
                },

            },
            rotate: {
                delay: 0
            },
            twitterId: 'swiss',
            control: false,
            filter: false,
            wall: true,
            cache: false,
            max: 'limit',
            limit: 16,
        });

    }
    socialStream();// first time load
    setInterval(function () {
        socialStream(); // reload div after every 5 seconds
    }, 5000); // 5 seconds interval
});

你也可以使用 clearInterval停止重新加载/刷新您的推特数据

关于javascript - 一定时间后重新加载特定的 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27289603/

相关文章:

javascript - 垂直反向滚动和水平滚动

javascript - 按 id 而不是按值选择选项

html - 下拉菜单无法正常工作

javascript - 为什么在 Facebook Flux 上使用 Redux?

javascript - 使用淡入淡出切换 <div> 内容

javascript - 闭包编译器 --debug 解决了我的错误

javascript - 自动刷新包含在 DIV 中的 PHP 文件

javascript - 在 JavaScript 中更改图像的位置

html - <li> 项在移动版中出现在同一行

php - 使用 TCPDF 和特定 div 作为内容创建 PDF