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

235
Views
How to add animation when changing element style in JS?

I want to add a slide down animation to the element when display being set to block, and a slide up when it's none or '', here's my actual js script:

<script>
  function showQuick(element, icon) {
    var style = element.style
    if (style.display === '') {
      style.display = 'block';
      icon.style.color = '#00FFFF';
      icon.style.filter = 'drop-shadow(0 0 0.35rem #00FFFF)';
    } else if (style.display === 'none') {
      style.display = 'block';
      icon.style.color = '#00FFFF';
      icon.style.filter = 'drop-shadow(0 0 0.35rem #00FFFF)';
    } else {
      style.display = 'none';
      icon.style.color = '#D2042D';
      icon.style.filter = 'drop-shadow(0 0 0.35rem #D2042D)';
    };
  };
</script>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

just try this, it is simple

div {

  position: absolute;
  top: -20px;
  
  transition: top 1s;

}
<div>hello everyone!</div>

now when you set style.top = "0px"; in your code, you will get a sliding effect

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!