Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
Created September 24, 2010 18:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sindresorhus/595803 to your computer and use it in GitHub Desktop.
Save sindresorhus/595803 to your computer and use it in GitHub Desktop.
jQuery plugin - Returns a random element
$.fn.random = function() {
var rand = Math.floor( Math.random() * this.length + 1 );
return this[rand];
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment