javascript geta element random and add class code example
Example: add class to random element
setRandomClass();
setInterval(function () {
setRandomClass();
}, 2000);//number of milliseconds (2000 = 2 seconds)
function setRandomClass() {
var ul = $("ul");
var items = ul.find("li");
var number = items.length;
var random = Math.floor((Math.random() * number));
items.removeClass("special");
items.eq(random).addClass("special");
}