Skip to content

Instantly share code, notes, and snippets.

@ksk1015
Created July 8, 2013 03:01
Show Gist options
  • Save ksk1015/5945926 to your computer and use it in GitHub Desktop.
Save ksk1015/5945926 to your computer and use it in GitHub Desktop.
return a random item
(function($){
$.fn.random = function(){
var index = Math.floor(Math.random() * this.length);
return this.eq(index);
};
})(jQuery);
// $("elem").random()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment