If $('.my-element')
matches multiple element, is there a quick way to get a random element out of these?
$.fn.random = function() {
return this.eq(Math.floor(Math.random() * this.length));
}
$(selector).random();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With