Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

121
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!