ミリ秒の値をループしようとしています。彼がループから取得した値に応じて、xxxx 秒ごとにいくつかのコードを実行する必要がありますが、それを機能させることはできません。
コードにはリセットボタンが含まれています(コードはプラグインからのものですが、変更する必要がありました)
//プラグインオプション
step:[
{
time: 6000,
// more stuff here
// but we dont need
// it in this example
},
{
time: 3000,
// more stuff here
// but we dont need
// it in this example
},
{
time: 12000,
// more stuff here
// but we dont need
// it in this example
}
]
// ループ
var timeouts = [];
$.each(options.step, function(i, value){
var time = value.time;
timeouts.push(setTimeout(function(){
alert('some action');
},time*i));
});
// リセットボタン
$('.stop').click(function(){
$.each(timeouts, function (_, id) {
clearTimeout(id);
});
timeouts = [];
})