i have the next html code
<div class="item item1"></div>
<div class="item item2"></div>
<div class="item item3"></div>
...
<div class="item item40"></div>
i want to choose random array of divs to add an active class to them for that i use this jquery code
function randOrder() {
return ( Math.round(Math.random())-0.5 );
}
$(document).ready(function() {
var items = [ 'item1', 'item2', 'item3', 'item4', 'item5', 'item6', 'item7', 'item8', 'item9', 'item10', 'item11', 'item12', 'item13', 'item14', 'item15', 'item16', ... , 'item40' ];
var randitems = items.sort( randOrder ).slice(0,5);
});
now i want to set an interval to the randitems to choose a random of classes to add "active" class to them . but how i can make a loop for that , i want to choose rando divs with active class every 1000ms without refreshing of page
Aucun commentaire:
Enregistrer un commentaire