Is there a way to assign each image a unique random class instead of giving all the images the same random class?
Any help would be appreciated.
$(document.body).ready(function () {
bgImageTotal = 5;
randomNumber = Math.round(Math.random() * (bgImageTotal - 1)) + 1;
$('img').addClass('img' + randomNumber);
});
.img1{max-height:10px}
.img2{max-height:40px}
.img3{max-height:70px}
.img4{max-height:100px}
.img5{max-height:130px}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img src="http://i.imgur.com/YeDYzSR.png">
<img src="http://i.imgur.com/YeDYzSR.png">
<img src="http://i.imgur.com/YeDYzSR.png">
<img src="http://i.imgur.com/YeDYzSR.png">
<img src="http://i.imgur.com/YeDYzSR.png">
<img src="http://i.imgur.com/YeDYzSR.png">