/ Published in: jQuery
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
// 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();