Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Object.extend(Array.prototype, {
- shuffle : function() {
- this.sort( function() { return 0.5 - Math.random(); } );
- return this;
- }
- });
- var intervalMilliseconds = X; // set to your value for X
- var divFoos = $("div.foo").get();
- var intervalId = setInterval(function() {
- $(divFoos.splice(Math.floor(Math.random() * divFoos.length), 1)).show();
- if(divFoos.length == 0) clearInterval(intervalId);
- }, intervalMilliseconds);
- (function () {
- var int, els;
- int = 100; // interval, in milliseconds
- els = $('div.foo');
- setInterval(function () {
- var idx;
- idx = Math.floor(els.length * Math.random());
- $(els[idx]).show();
- setTimeout(function () {
- $(els[idx]).hide();
- }, int);
- }, int);
- })();
Add Comment
Please, Sign In to add comment