I have 12 elements with class "block" and I need to add class "active" to 6 of 12 elements (randomly).
I think using for loop would to the trick but I am not sure how to do it. Maybe somebody can help me out?
for (var i = 0; i < 6; i++) {
var random = Math.floor(Math.random() * 1000);
block.eq(random % block.length).addClass("active");
}
This code adds class, but it's not 6 elements every time.. Need a solution to add "active" class to 6 elements every time. Now sometimes it's 6, sometime less..