javascript - Showing random divs images every time page is load -
lets have these images gallery, how randomly display images everytime when reload page?
you along these lines (not tested)
var grd = $('#grid'); var imgs = grd.children(); imgs.sort(function(){return (math.round(math.random()) - 0.5);}); grd.remove('li'); for(var i=0;i < imgs.length;i++) grd.append(imgs[i]);
in essence doing getting li elements in 'grid' array, randomizing them, removing them 'grid' , putting them in again.
if had supplied working fiddle rather link finished article easier modify , provide more complete solution.
Comments
Post a Comment