Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9045295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:15:26+00:00 2026-06-16T11:15:26+00:00

I make a small jquery script. When you scroll on the page and your

  • 0

I make a small jquery script. When you scroll on the page and your are over 350. Than a button is show. When you going back, the button is hide. This is the script:

var button = $('a[title*="terug naar boven"]');

$(document).bind('scroll', function(e) {
    if (window.scrollY > 350) {
        button.animate ({
            opacity: 1
        })
    }
    if (window.scrollY < 350) {
        button.animate ({
            opacity: 0
        })
    }
});

But the problem is. That the script succession is. When i scroll. The script is fire everytime. How can i fix this? That is script is fire one time.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:15:29+00:00Added an answer on June 16, 2026 at 11:15 am

    To prevent the button from being animated if its already in the right state (either shown or hidden), you should maintain state of the button.

    You can use a variable to do this

    var buttonState = 0;
    $(document).bind('scroll', function(e) {
        if (window.scrollY > 350 && buttonState == 0) {
            buttonState = 1;
            button.animate ({
                opacity: 1
            })
        }
        if (window.scrollY < 350 && buttonState == 1) {
            buttonState = 0;
            button.animate ({
                opacity: 0
            })
        }
    });
    

    Alternatively, you can also use the button’s opacity level as state

    If you want to run this only once, you can unbind handlers for the event

    $(document).bind('scroll', function(e) {
        if (window.scrollY > 350) {
            button.animate ({
                opacity: 1
            })
        }
        if (window.scrollY < 350) {
            button.animate ({
                opacity: 0
            })
        }
        $(document).unbind('scroll');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was wondering if it was possible to make a small script in Jquery
Experimenting with jQuery and trying to make a small slide show that rotates through
I'm trying to make a small radius with the AudioPlaybackAgent as Microsoft show in
I'm trying to make a small Python script that is executed by clicking an
I am attempting to make a registration-like page for a small forum. To register
I am writing a small jQuery animation script that simulates a delivery man walking
Basically, what I'm trying to do is simply make a small script that accesses
I have made small jquery collapse/expand script http://jsfiddle.net/goldie/QFL49/ (please don't pay attenton to html/css
I am trying to make small calculator in jquery but don't know where to
I've been trying to make a multi-page poll with jQuery Mobile that is supposed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.