Revision: 49805
Updated Code
at September 21, 2011 23:18 by smashu
Updated Code
// slice(0,1) -> 1 is the number of random elements from the $(selector) randomElement = $(selector).get().sort(function(){ return Math.round(Math.random())-0.5 }).slice(0,1); // use element $(randomElement).doSomething();
Revision: 49804
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at July 30, 2011 05:03 by smashu
Initial Code
jQuery.jQueryRandom = 0; jQuery.extend(jQuery.expr[":"], { random: function(a, i, m, r) { if (i == 0) { jQuery.jQueryRandom = Math.floor(Math.random() * r.length); }; return i == jQuery.jQueryRandom; } });
Initial URL
Initial Description
Initial Title
jquery random selector
Initial Tags
jquery
Initial Language
jQuery