[問題] jQuery each的變數範圍
我想做多個檔案上傳,再配合jquery的 progressbar這個plugin
目前的html是一個開始上傳的按鈕
<span id="start_upload" class="onclick">開始上傳</span>
和多個progressbar
<div class="progress inline">20%</div>
<div class="progress inline">30%</div>
<div class="progress inline">40%</div>
我的js是這樣
$('.start_upload').click(function(){ //按下去之後,透過each
$('.progress').each(function(){
setInterval(function() {
$.getJSON("demo.php?id=" + progress_key, function(data) {
if (data == null)
return;
var percentage = Math.floor(100 * parseInt(data.bytes_uploaded) /
parseInt(data.bytes_total));
$(this).progressBar(percentage);
//問題在這裡,怎麼指定是 each目前的物件
});
}, 1500);
$(this).progressBar
});
});
請問我要怎麼把each 目前的索引的物件丟到setInterval 裡面去呢
謝謝回答
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 59.126.209.219
推
08/24 17:26, , 1F
08/24 17:26, 1F
Ajax 近期熱門文章
PTT數位生活區 即時熱門文章
10
18