【发布时间】:2012-06-01 12:25:30
【问题描述】:
我有一个通过对象的每个循环,
在其中,我创建了一些图像,我想在其中放入对上次迭代中图像的引用的数据。
例如:
.each((function(some_data){ return function(i, obj){
var prev='???'; // how do I retrieve the value from the last cycle?
var image=new Image();
image.data('prev',prev);
prev=image;
// how do I pass the value to next cycle?
}})(some_data));
【问题讨论】:
-
把你的
prev定义放到each块之外。 -
哦,我从来没想过……但这听起来是个好主意!
标签: javascript jquery image recursion iteration