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

114
Visualizações
Does the order of parameters in classList methods matter?

I have four css classes that seperated based on their functionality, .openModalStyle and .closeModalStyle contain appearing/disappearing styles, .openModalTransition and .closeModalTransition contain transition property for that styles.

I want to know if the order of tokens matter for classList methods or not, because transition should be attached before styles.

let modal = document.querySelector("modal");

// style before transition
modal.classList.add("openModalStyle");
modal.classList.add("openModalTransition");


// transition before style
modal.classList.add("openModalTransition");
modal.classList.add("openModalStyle");

// want to make sure both work properly in all browsers
    .modal{
      width: 200px;
      height: 200px;
      background-color: #f00;
    }
    
    
    /* change opacity */
    .openModalStyle{
      opacity: 1;
    }
    .closeModalStyle{
      opacity: 0;
    }


    /* apply transitions */
    /* they are repeated styles, but i need to keep them seperated for some reason */

    .openModalTransition{
      transition: opacity 2s;
    }
    .closeModalTransition{
      transition: opacity 2s;
    }
<div class="modal"></div>

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

0

No, it doesn't matter in the classList as you just adding a class to the element,

Also, the order at CSS in most cases doesn't matter, only in some cases it matters, It comes up any time multiple CSS selectors match an element with the exact same specificity.

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