document.querySelectorAll('.your-element-class').forEach(function(element) { // Generate a random delay between 0 and 3 seconds var randomDelay = Math.random() * 3; // Set the delay using inline styling element.style.setProperty('animation-delay', randomDelay + 's'); });