There is a method:
Menu.prototype.init = function () { var self = this; function sliding(item, step) { var i = 0; var imgs = Array.prototype.slice.apply(item.querySelectorAll('img')); var len = imgs.length; function next() { imgs[i].style.opacity = 0; if(i == len - 1) { imgs[0].style.opacity = 1; } else { imgs[i+1].style.opacity = 1; } i++; if(i == len) { i = 0; } console.log(i); } setInterval(next, step); } function start(items, step) { for(var i = 0; i < items.length; i++) { step += 200; (function(i, step) { sliding(items[i], step); })(i, step); } } start(this.items, 3000); } The method works but not as intended, as I understand it is in the timers .. The idea was that the pictures would change consistently and when you first start it happens ... but then they begin to change chaotically. Tell me the direction of finding a solution? See the script here.