作者knives ()
看板Ajax
标题[问题] jQuery each的变数范围
时间Wed Aug 24 16:59:48 2011
我想做多个档案上传,再配合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
1F:推 senser:each里var t=$(this) 然後setInterval里去找t 08/24 17:26