Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript [Solved] Unique random number Re: [Solved] Unique random number

#78932
carlgordon
Member

Thanks lookslikepat.

I had my question answered on another forum and I adapted my script to this…


$(function () {
var ar = [];
function returnRandomUnique() {
if ( ar.length) {
return 'url(clouds/' + ar.splice(Math.floor(Math.random() * ar.length) ,1) + '.jpg)';
} else {
for (var i = 76; i > 0; i--)
ar[ar.length] = i;
}
}
returnRandomUnique();
$('.cloud1').css('background-image', returnRandomUnique());

$('.cloud15').css('background-image', returnRandomUnique());
});

Your script looks good with nice descriptions. Many thanks for your time.