How do I write this function more efficient? My class names always contain modell
and essentially, only the numbers are changing. Is it right that I get a better performance if I update the numbers instead of adding and removing classes ?
So basically: modell[1]
, modell[2]
, ...
jQuery(document).ready(function(){
animatemodels();
});
function animatemodels() {
var classes = [ 'modell1', 'modell2', 'modell3', 'modell4', 'modell5', 'modell6', 'modell7', 'modell8', 'modell9', 'modell10', 'modell11', 'modell12', 'modell13', 'modell14', 'modell15', 'modell16', 'modell17', 'modell18', 'modell19', 'modell20', 'modell21', 'modell22', 'modell23', 'modell24', 'modell25', 'modell26', 'modell27', 'modell28', 'modell29', 'modell30', 'modell31', 'modell32', 'modell33', 'modell34', 'modell35', 'modell36', 'modell37', 'modell38', 'modell39', 'modell40', 'modell41', 'modell42', 'modell43', 'modell44', 'modell45', 'modell46', 'modell47', 'modell48', 'modell49', 'modell50', 'modell51', 'modell52', 'modell53', 'modell54', 'modell55', 'modell56', 'modell57', 'modell58', 'modell59', 'modell60', 'modell61', 'modell62', 'modell63', 'modell64', 'modell65', 'modell66', 'modell67', 'modell68', 'modell69', 'modell70'];
jQuery(".panzoom").each(function(){
jQuery(this).removeClass('modell1 ' + classes.join(' ')).addClass(classes[~~(Math.random()*classes.length)]);
});
setTimeout(animatemodels, 7000);
}