I'm creating a rolodex type animation and I'm using timers to set a class for 3d animation and setting the z-index dynamically as well in order for the elements to overlay and underlay each other when needed. Every second I'm expecting the bottom span (divs.children[1]) to have the class and style attributes set, and then halfway between that second, I expect the bottom to remove the attributes and the top half (divs.children[0]) to begin it's animation. 
When I use the code below, every call to hideTop(), showTop(), and showBottom() work as expected, but whenever hideBottom() is called, neither the style or class attributes are being removed. I've also tried using setAttribute("style", ""), but to no avail. I was using setInterval(function() { ... }, 1000) before which produced the same behavior as well.
Codepen as well.
    var i = 0;
    var x = 100;
    var firstRun = true;
    var digit = document.getElementById("digit");
    var divs = digit.getElementsByTagName("div");
    divs[0].children[0].setAttribute("style", "-webkit-transform: rotateX(0deg);");
    (function scrollRolodex() {
        function showTop(i, x) {
            divs[i].children[0].setAttribute("style", "z-index: " + ((i * x) + 10));
            divs[i].children[0].setAttribute("class", "flip-top");
        }
        function hideTop(i) {
            divs[i].children[0].removeAttribute("style");
            divs[i].children[0].removeAttribute("class");
        }
        function showBottom(i, x) {
            divs[i].children[1].setAttribute("style", "z-index: " + ((i * x) + 5));
            divs[i].children[1].setAttribute("class", "flip-bottom");       
        }
        function hideBottom(i) {
            divs[i].children[1].removeAttribute("style");
            divs[i].children[1].removeAttribute("class");
        }
        if (i < divs.length) { 
            if (i == 0 && !firstRun) {
                hideTop(divs.length - 1);
            } else if (i > 0) {
                hideTop(i - 1); 
            }
            showBottom(i, x);
            window.setTimeout(function() {
                hideBottom(i);
                if (i != (divs.length - 1)) {
                    showTop(i, x);
                } else {
                    showTop(divs.length - 1, x);
                }
            }, 500);
            if (i == divs.length - 1) {
                i = 0;
                x = 100;
                firstRun = false;
            } else {
                i++;
                x++;
            }
        }
        setTimeout(scrollRolodex, 1000);
    }());
Thanks!
 
     
    