我有一组主题。我试图遍历它们并添加课程"焕发"根据我指定的秒数,一次一个地给他们。当一个元素发光时,前一个元素不再发光。
<div class="center" id="topics">
<div class="row">
<div class="topic" id="fade1">Introduction and Overview</div>
<div class="topic" id="fade4">Topic 6</div>
<div class="topic" id="fade7">Accounting Topic</div>
</div>
<div class="row">
<div class="topic" id="fade2">Topic Navigation</div>
<div class="topic" id="fade5">Topic Changes</div>
<div class="topic" id="fade8">Topic 8</div>
</div>
<div class="row">
<div class="topic" id="fade3">More Topics</div>
<div class="topic" id="fade6">Elements</div>
<div class="topic" id="fade9">Conclusion</div>
</div>
</div>
这是我定义它们发光的秒间隔的方式。所以当一个人发光时,其余部分就不再发光了。
$.glowElements([
{target: "#fade1", seconds: 4},
{target: "#fade2", seconds: 9},
{target: "#fade3", seconds: 20},
{target: "#fade4", seconds: 22},
{target: "#fade5", seconds: 23},
{target: "#fade5", seconds: 24}
]);
我处理光晕的代码:
$.glowElements = function(list){
if(!USE_AUDIO){ return; }
$(list).each(function(index, element){
// remove all glows first
$(".row > div").removeClass("glow");
timers.push(setTimeout(function(){
$(element.target).addClass("glow");
},element.seconds * 1000));
});
}
我的$(".row > div").removeClass("glow");
无效?有什么想法吗?
答案 0 :(得分:3)
简单方法
$(".glow").removeClass("glow");
然后添加
$(element.target).addClass("glow");