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 6974357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:13:36+00:00 2026-05-27T17:13:36+00:00

I made a script that fades out a button when the mouse goes over

  • 0

I made a script that fades out a button when the mouse goes over it and fades in on mouse out. It works fine on the ‘mouseover’ event, but it fails on the ‘mouseout’ any ideas?

P.S. I not using jquery because I am trying to learn this for educational purposes.

Go here to see the code: http://jsfiddle.net/assuredlonewolf/t2sYX/
Feel free to edit it!

  • 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-05-27T17:13:37+00:00Added an answer on May 27, 2026 at 5:13 pm

    You’ve got two issues:

    • The interval is created multiple times, and cleared nowhere
    • You’re using < 1.1 to determine whether the element should become visible or not, while the fade count start at 1.1. Clearly, 1.1 is never lower than 1.1.

    Updated code, feel free to ask help if you’re having trouble implementing it:

    var interval; // Declare a variable to hold the timer OUTSIDE the function, 
                  //  so that all event listeners can work with ONE interval
    function fade(elem, speed, mode) {
        var count = 0;
        var fade = 1.0;
        clearInterval(interval); // Clear interval, to prevent having multiple
                                 //  running intervals
        if (mode === true && count == 0) {
            count = 1;
            interval = setInterval(function() {
                fade = fade - .1;
                if(fade > -.1) document.getElementById(elem).style.opacity = fade;
            }, speed)
        } else {
            count = 0;
            interval = setInterval(function() {
                fade = fade + .1;
                // Updated code below: Replaced < with <=
                if(fade <= 1.1) document.getElementById(elem).style.opacity = fade;
            }, speed)
        }
    }
    

    Additional tips:

    • Store document.getElementById(elem) in a variable, outside the interval function (but inside function fade, for performace reasons. A varibale look-up is less expensive than a function call.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have successfully made a script that filters out duplicate lines in a file
I've made this script that lets you navigate through multiple divs with jQuery, but
I made a c extension out of a python script that was fairly labour
I made a script that spawns a remote shell or runs a local shell
What happes when the script that made @mysql_connect($server, $user, $password) dies? How long does
Some time ago I made a script that takes some text and returns it
I made a shell script that finds the size of a directory, returning it
I've made a pure PHP script that uses GD library to put text on
I understand that a Batch Script is what you call a script made in
Ok, basicly, I made a script (that one) that makes a .post to a

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.