简体   繁体   English

转换在Javascript中不起作用

[英]Transform doesnt work in Javascript

This is my code when the page starts up. 页面启动时,这是我的代码。

    var x = document.getElementById('mainNav').getElementsByTagName("LI");
    var delay = 0;
    var transition = 0.3;
        for (i=0; i<=x.length; i++){
            x[i].style.WebkitTransfrom = "translate3d(250px,0,0)";
            x[i].style.transition = "-WebkitTransform " +transition + "s " + delay +"s";
            //x[i].innerHTML = "changed";
            delay += 0.04;
        }

This is my code when I click the button. 这是我单击按钮时的代码。

var x = document.getElementById('mainNav').getElementsByTagName("LI");
            var delay = 0;
            var transition = 0;
                for (i=0; i<=x.length; i++){
                    x[i].style.WebkitTransform = "translate3d(0px,0,0)";
                    x[i].style.transition = "-WebkitTransform " +transition + "s " + delay +"s";
                    delay += 0.02;
                    transition += 0.04; // The higher the number, the slower of exponential decay
                    if (x[i].querySelectorAll('ul li').length>0){
                        x[i].style.background = "rgba(0,0,0,0.35)";
                        }
                    //x[i].innerHTML = "changed";
                }

When I click another button it goes through the same code when it starts. 当我单击另一个按钮时,启动时它会经过相同的代码。 AKA closing it back. 又将其关闭。

It used to work, but now it doesnt. 它曾经可以工作,但是现在不行了。 What happened was that I told these functions to call others to simplify code (Doesnt affect these in any way). 发生的是,我告诉这些函数调用其他函数来简化代码(不会以任何方式影响它们)。 I'm not sure why its not working. 我不确定为什么它不起作用。

Is there some syntax gone wrong? 语法有问题吗?

这是一个错误的错误。

x.length-1;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM