我有一個每個循環雖然對象,jquery如何從最後一次迭代傳遞變量?
而在其中,我創建了一些圖像,我想把它們的數據引用到最後一次迭代的圖像。
例如:
.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'定義放在''每個'塊之外。 – VisioN
哦,我從來沒有想過......但這聽起來像個好主意! – Anonymous