3
respostas

Executa mas este erro aparece na console "[Violation] 'click' handler took 1699ms"

<!DOCTYPE html>
<html lang="pt-br">
    <head>
            <meta charset="UTF-8">
            <link rel="stylesheet" type="text/css" href="introducao-javascript/css/reset.css">
            <link rel="stylesheet" type="text/css" href="introducao-javascript/css/index.css">
    </head>
    <body>
        <main>
            <ul>
                <li>A</li>
                <li>B</li>
                <li>C</li>
            </ul>
            <script>

                var lis = document.querySelectorAll('li');

                for(var i = 0; i < lis.length; i++) {

                    lis[i].addEventListener('click', function() {

                        alert(this.textContent);
                    });
                };
            </script>
        </main>
    </body>
</html>
3 respostas

Cida,

Tudo bem?

Você poderia compartilhar o código?

<!DOCTYPE html>
<html lang="pt-br">
    <head>
            <meta charset="UTF-8">
            <link rel="stylesheet" type="text/css" href="introducao-javascript/css/reset.css">
            <link rel="stylesheet" type="text/css" href="introducao-javascript/css/index.css">
    </head>
    <body>
        <main>
            <ul>
                <li>A</li>
                <li>B</li>
                <li>C</li>
            </ul>
            <script>

                var lis = document.querySelectorAll('li');

                for(var i = 0; i < lis.length; i++) {

                    lis[i].addEventListener('click', function() {

                        alert(this.textContent);
                    });
                };
            </script>
        </main>
    </body>
</html>
<!DOCTYPE html>
<html lang="pt-br">
    <head>
            <meta charset="UTF-8">
            <link rel="stylesheet" type="text/css" href="introducao-javascript/css/reset.css">
            <link rel="stylesheet" type="text/css" href="introducao-javascript/css/index.css">
    </head>
    <body>
        <main>
            <ul>
                <li>A</li>
                <li>B</li>
                <li>C</li>
            </ul>
            <script>

                var lis = document.querySelectorAll('li');

                for(var i = 0; i < lis.length; i++) {

                    lis[i].addEventListener('click', function() {

                        alert(this.textContent);
                    });
                };
            </script>
        </main>
    </body>
</html>