Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

160
Visualizações
Live Lists example DomTokenList values

I have a question regarding the console output of the DomTokenList(in general live lists). Why does the first console output also show the 3 values instead of 2. Although I added the third class afterwards. I already set a timeout but the result is the same.

Thanks & Have a nice Sunday

<!DOCTYPE html>
<html lang="en">

<head>

    <style>
.eins {background-color:orange;height:50px;}
.zwei {color:red;}
.drei {width:50px;}

    </style>

</head>

<body>
    <div class="eins zwei">JS</div>

    <script>
var eins=document.querySelector("div");
var klasse=eins.classList;
console.log(klasse);
setTimeout(b,1000);
function b(){
eins.classList.add("drei");
console.log(klasse);}

    </script>

</body>

</html>

Screenshot console output

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Looks good to me, please see the screenshot

about 4 years ago · Juan Pablo Isaza Relatório

0

It will be updated later. If you set the delay to say 10 seconds and open the list immediately, it contains only 2 items. But it's even easier if you use console.log (klasse.length). It gave me 2 ... 3.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda