what’s the best way to add a class to the div with a class of post every 4 seconds using jquery? [closed]
var post_count = $(‘.post’).length, current_index = 0; setInterval(function(){ $(‘.post’).removeClass(‘display’).eq(current_index).addClass(‘display’); current_index++; if(current_index > post_count) current_index = 0; }, 4000); Wrap it in a jQuery document.ready function 🙂