const children = banner.querySelectorAll(".banner"); const len = children.length; let index = [...children].indexOf(banner.querySelector(".visible")|| children[len - 1]);