Simple Gallery does not want to run

0

I'm trying to use a javascript code only that I do not know anything about.

I learned the basic video class online, I still do not know how to create a code, I took the one here on the site, but this code does not want to run.

(I do not know if I should create a .js file or put this code with type = text / javascript script).

Note: I tried both modes and it did not work, if someone has another code or a solation thank you.

"I want to make the slides from Nintendo's website, now I'm trying to make the number that runs on the Nintendo DS gallery."

java.js:

function iniciarSlideImagens() {


var exibirImagens = function(current) {
    var arrImgsAmarelas = [ 'contador0.png', 'contador1.png' ];
    var arrImgsLaranjas = [ 'contador2.png', 'contador3.png' ];

    document.getElementById("imagem").src = "cores-roleta/" + arrImgsAmarelas[current];
    document.getElementById("imagem1").src = "cores-roleta/" + arrImgsLaranjas[current];

    if (++current >= arrImgsAmarelas.length) {
        current = 0;
    }

    setTimeout(function() { exibirImagens(current); }, 1000);
};

exibirImagens(0);


}
if(2>1){
iniciarSlideImagens();

}

HTML:

<img id="imagem" src="cores-roleta/contador0.png">
<img id="imagem1" src="cores-roleta/contador2.png">
    
asked by anonymous 12.09.2017 / 02:09

1 answer

0

Code working, what you had to do was to start the "startSlideImages" call, which would be onclick="iniciarSlideImagens()" in the div or put in the function, window.onload = function(){ that would start the script when accessing the site.

Complete code with html and jquery.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Site</title>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script></head><body><scripttype="text/javascript">
        window.onload = function(){


            var exibirImagens = function(current) {
                var arrImgsAmarelas = [ 'contador0.png', 'contador1.png' ];
                var arrImgsLaranjas = [ 'contador2.png', 'contador3.png' ];

                document.getElementById("imagem").src = "cores-roleta/" + arrImgsAmarelas[current];
                document.getElementById("imagem1").src = "cores-roleta/" + arrImgsLaranjas[current];

                if (++current >= arrImgsAmarelas.length) {
                    current = 0;
                }

                setTimeout(function() { exibirImagens(current); }, 1000);
            };

            exibirImagens(0);


        }
        if(2>1){
            iniciarSlideImagens();

        }
    </script>
    <img id="imagem" src="cores-roleta/contador0.png">
    <img id="imagem1" src="cores-roleta/contador2.png">
</body>
</html>

It is not necessary to put this code with script type=text/javascript HTML5 already recognizes that it is a code in javascript.

    
12.09.2017 / 04:06