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

97
Views
Jquery IMG Attr change keeps flickering while scrolling

I have a white menu icon in PNG format that I want to change to green menu icon in PNG format and I tried to use the fading effect. It works at first and changes on scroll but when I keep scrolling it keeps flickering the green icon, however it stops when I stop scrolling as well. I'm not sure why this is happening or how can I fix it, couldn't really find the related questions. I'd appreciate your help. Thanks in advance here is my code:

      $(window).scroll(function() {
          var scroll = $(window).scrollTop();

          if (scroll >= 50) {
            $(".show_nav img").fadeOut(function() {
              $(this).attr("src","../img/icons/menu-green.png").fadeIn();
            });

          } else {
            $(".show_nav img").fadeOut(function() {
              $(this).attr("src","../img/icons/menu-white.png").fadeIn();
            });
          }
      });
about 4 years ago · Juan Pablo Isaza
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!