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

146
Views
Add an addEventListner on a class remove

I made some fandeIn and fadeOut codes to an exercise. I'm trying to remove the setTimeout() on the fadeIn(). Like using an addEventListner maybe, but there is no transition on .displayNone.

On the MDN I just found transitions interacting with EventListner.

function fadeOut(disable) {
    disable.classList.remove('visible');
    disable.classList.add('hidden');
    disable.addEventListener('transitionend', () => disable.classList.add('displayNone'));
};

function fadein(enable, timer) {
    if (!timer) timer = 350;
    enable.classList.remove('displayNone');
    setTimeout(function () {
        enable.classList.remove('hidden');
        enable.classList.add('visible');
    }, timer);
};
.displayNone {
    display: none;
}

.visible {
    visibility: visible;
    opacity: 1;
    transition: opacity 1.5s linear;
}

.hidden {
    visibility: hidden;
    opacity: 0;
    transition: visibility 0s 350ms, opacity 350ms, display 350ms linear;
}

P.S.: This works good, I'm just trying another way to make it works too.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The setTimeout method returns a timeout descriptor/id (actually just an integer). You may use it to remove the timeout later:

// setting timeout
var timeout = window.setTimeout(function(){}, 5000);
window.clearTimeout( timeout )
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!