ループ内の現在の要素のクラスを異なるタイミングで変更する必要があります。異なる時刻のdivのループクラス
この場合、1回だけ発生します。/
任意の提案thx ??
<div class="wrapper">
<div class="wrapper-item wrapper-item--0 current" data-time="2500">
<div class="item"></div>
</div>
<div class="wrapper-item wrapper-item--1" data-time="5000">
<div class="item"></div>
</div>
<div class="wrapper-item wrapper-item--0" data-time="7000">
<div class="item"></div>
</div>
<div class="wrapper-item wrapper-item--0" data-time="9000">
<div class="item"></div>
</div>
</div>
function myFunction() {
var current = $('.wrapper').children(".current")
var timeOfVisible = $('.wrapper').children(".current").data("time");
setInterval(function() {
current.removeClass("current").next().addClass("current");
if ((current.next()) > $('.wrapper').children().length) {
alert(current)
}
}, timeOfVisible);
}
myFunction()
ので、あなたがたsetIntervalは差分で仕事をしたいです。 divあたりのデータ時間 –
ここに問題はありません。この機能をチェーンしたいという問題はありますか? –
私はそれのためにフィドルを準備するhttps://jsfiddle.net/xd9kw3qm/ –