我有标签列表,页面加载首先是活动的。但我想要的是经过一段时间的延迟后我想让第二个标签处于活动状态并再次使用第三个标签等。如何实现这一点请一些人帮助我。
以下是代码,
<ul class="list-style-none project-menu owl-carousel-picker owl-theme">
<!-- <ul class="list-style-none project-menu owl-carousel owl-theme"> -->
<!-- <h3 class="col-hidden-sm col-visible-xs">Pick Selector :</h3> -->
<!-- <span id="pick-selector">Pick Selector :</span> -->
<li class="active">
<a class="active" href="#tab1" data-toggle="tab" aria-expanded="true">
<div class="project-icon"><i class="retail-hm"></i></div>
</a>
</li>
<li>
<a href="#tab2" data-toggle="tab" aria-expanded="true">
<div class="project-icon"><i class="flaticon-transport"></i></div>
</a>
</li>
<li>
<a href="#tab3" data-toggle="tab" aria-expanded="true">
<div class="project-icon"><i class="bank-hm"></i></div>
</a>
</li>
</ul>
答案 0 :(得分:-1)
var i = 1;
var execute = function() {
$('#li_' + i).removeClass("active");
$('#a_' + i).removeClass("active");
i++;
if(i > 3) {
i = 1;
}
$('#li_' + i).addClass("active");
$('#a_' + i).addClass("active");
}
然后
setTimeout(execute, 1000)
或
setInterval(execute, 1000);
另外,为HTML标记添加id属性
<li id="li_0">
<a id="a_0">