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

143
Views
slideToggle works multiple times when watching screen resize

I'm trying to apply the slideToggle function over a menu based on screen size , but this code is applying the function multiple times with just one click , tried every solution here but nothing works .

I know the problem is the click event inside a window resize, but the application should be like that, so please i need alternative solution to have a working code.

$(window).on("resize", function () {
  if (screen.width < 768) {
    $(".part-heading").click(function (e) {
      $(this).next(".sections").slideToggle("slow");
    });
  }
});
almost 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You are registering multiple event listeners, one every time the screen size change. And when you click all of them will run. You can change your script as below, so check the size on each click rather than watching the resize:

$(".part-heading").click(function (e) {
  if (screen.width < 768) {
    $(this).next(".sections").slideToggle("slow");
  }
});
almost 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!