This article illustrates the waterfall load effect of jquery implementation. Share to everyone for your reference, specific as follows:
Demo.js:
$ (function () {$ (' img '). Load (function () {var box = $ ('. box ');
var boxheight = {leftbox:[], centerbox:[], rightbox:[]} for (Var i=0;i<box.length;i++) { var now = i%3;
Now the value is 0,1,2 switch (now) {case 0:box.eq (i). CSS (' left ', ' 10px ');
BoxHeight.leftBox.push (Box.eq (i). height ());
var now2 = Math.floor (I/3);
if (now2==0) {box.eq (i). CSS (' top ', 0);
}else{var total = 0;
for (Var j=0;j<now2;j++) {total + = boxheight.leftbox[j]+10;
} box.eq (i). CSS (' top ', total+ ' px ')} break;
Case 1:box.eq (i)-css (' left ', ' 270px ');
BoxHeight.centerBox.push (Box.eq (i). height ());
var now2 = Math.floor (I/3);
if (now2==0) {box.eq (i). CSS (' top ', 0);
}else{var total = 0; for (Var j=0;j<now2;j++) {Total + = Boxheight.centerbox[j]+10;
} box.eq (i). CSS (' top ', total+ ' px ')} break;
Case 2:box.eq (i)-css (' left ', ' 530px ');
BoxHeight.rightBox.push (Box.eq (i). height ());
var now2 = Math.floor (I/3);
if (now2==0) {box.eq (i). CSS (' top ', 0);
}else{var total = 0;
for (Var j=0;j<now2;j++) {total + = boxheight.rightbox[j]+10;
} box.eq (i). CSS (' top ', total+ ' px ')} break;
}
}
});
});
Demo.html:
The effect chart is as follows:
More interested readers of jquery-related content can view the site topics: "jquery Extended Tips," "jquery common Plug-ins and Usage summary", "jquery drag-and-drop effects and tips summary", "jquery table (table) Operation Tips Summary", " A summary of Ajax usage in jquery, a summary of common classic effects in jquery, a summary of jquery animation and special effects usage, and a summary of jquery selector usage
I hope this article will help you with the jquery program design.