jQuery EasyUI 布局 - 添加自动播放标签页(Tabs)

jQuery EasyUI 教程 · 2019-04-06 11:37:45

本教程将向您展示如何创建一个自动播放的 Tabs。 Tabs 组件显示第一个 tab 面板,然后显示第二个、第三个... 我们将写一些代码来自动地切换 tab 面板,然后让它循环。

步骤 1:创建 Tabs

    <div id="tt" class="easyui-tabs" style="width:330px;height:270px;">
        <div title="Shirt1" style="padding:20px;">
            <img src="images/shirt1.gif">
        </div>
        <div title="Shirt2" style="padding:20px;">
            <img src="images/shirt2.gif">
        </div>
        <div title="Shirt3" style="padding:20px;">
            <img src="images/shirt3.gif">
        </div>
        <div title="Shirt4" style="padding:20px;">
            <img src="images/shirt4.gif">
        </div>
        <div title="Shirt5" style="padding:20px;">
            <img src="images/shirt5.gif">
        </div>
    </div>

步骤 2:写自动播放代码

    var index = 0;
    var t = $('#tt');
    var tabs = t.tabs('tabs');
    setInterval(function(){
        t.tabs('select', tabs[index].panel('options').title);
        index++;
        if (index >= tabs.length){
            index = 0;
        }
    }, 3000);

正如您所看到的,我们调用 'tabs' 方法来得到所有 tab 面板,并使用 'setInterval' 函数来切换他们。

下载 jQuery EasyUI 实例

jeasyui-layout-tabs3.zip

点击查看所有 jQuery EasyUI 教程 文章: https://codercto.com/courses/l/42.html

查看所有标签

The Four

The Four

Scott Galloway / Portfolio / 2017-10-3 / USD 28.00

NEW YORK TIMES BESTSELLER USA TODAY BESTSELLER Amazon, Apple, Facebook, and Google are the four most influential companies on the planet. Just about everyone thinks they know how they got there.......一起来看看 《The Four》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

UNIX 时间戳转换
UNIX 时间戳转换

UNIX 时间戳转换

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试