var isEven = function(someNumber) { return someNumber % 2 === 0; }; if (!isEven(count)) { $(this).toggleClass('my3d'); $(".main-menu a").removeAttr("class"); $(".main-cube").animate({top: "0%"}, 1000); $(".cube").css({width: "95vw", height: "45vh", transform: "rotate3d(0,1,0,0deg)", left: "0"}); $(".side").addClass("landing-loft").css({width: "80vw", height: "100vh"}); } // on even clicks do this else if (isEven(count) === true) { $(".main-menu a").attr("class"); $(".main-cube").css("top", "10%"); $(".cube").css({width: "600px", height: "600px"}); $(".side").removeClass("landing-loft").css({width: "600px", height: "600px"}); } }); The upper part is working, lower in principle, too, but with the help of $(".main-menu a").attr("class"); I can’t go back to return the class attribute so the cube rotates. How can I get it back?