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

245
Visualizações
How to access HTML element when I use module css

I am doing styling using module css and I wonder how I can access to an element with document.querySelector. It seems when I use module css, classname of an element is hashed so I can not access to the element by simply using document.querySelector('.some-classname'). I am not using any framework here so I can not use useRef.

enter image description here

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

0

When selecting an element by classNames you are getting an array of the elements even if the class name is only used one time.

Gives you the array of elements:

const elements = document.getElementsByClassName('className'); 

If you only have one element with this class you can style it like this:

elements[0].style.backgroundColor = "green";
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