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

144
Views
call a function when slideDown or slideUp effect has finished

I have a simple dropdown list, I want when the user toggles the dropdown list to show or hide another div using the jquery method slideToggle, unfortunately, I am struggling to solve the problem.

Expected: when the user clicks an icon it should show the list and hide another div (slideDown effect) when the user clicks again for closing the dropdown list (slideUp effect), I want to show the hidden div.

 var link = $('.sprzatanie-link');

  link.click(function(e) {
    e.preventDefault();
    list.slideToggle("fast", function(){
      console.log('do something')
      if("slideDown"){
        $('.dezynfekcja-dropdown').hide();
      }else if("slideUP"){
        $('.dezynfekcja-dropdown').show();
      }
    });
  });

I tried adding a callback function but I don't know how to check the slide effect if it's slideDown or slideUp.

Any idea will be appreciated.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Once toggle finishes it basically hides or shows the element being toggled. So in the complete callback you can simply check if your element is shown or hidden.

 var link = $('.sprzatanie-link');

  link.click(function(e) {
    e.preventDefault();
    list.slideToggle("fast", function(){
      // `this` refers to the DOM element being toggled.
      // We can use `is(":visible")` to check if it visible or not
      let isVisible = $(this).is(":visible");

      // show console message that tells us if element is hidden or visible
      console.log(this.innerText, ' is now ', isVisible);

      // use isVisible to do whatever you want show/hide etc
      if(isVisible) {
        $('.dezynfekcja-dropdown').hide();
      } else {
        $('.dezynfekcja-dropdown').show();
      }
    });
  });
about 4 years ago · Santiago Trujillo 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!