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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:32:17+00:00 2026-06-04T21:32:17+00:00

I am trying to fiddle around and create a little fadeOut function in JavaScript,

  • 0

I am trying to fiddle around and create a little fadeOut function in JavaScript,
This is what I came up with:

function fadeOut(id, time){
  var elem = document.getElementById(id);
   elem.style.opacity = 1;
   var opc = 1;
   while(opc >= (1/time)){
      opc -= (1/time);
      console.log(opc);
      elem.style.opacity = opc;
   }
   elem.style.opacity = 0;
}

But this will not show the div’s opacity in “real-time” but rather the end result, which is opacity = 0;
I’ve tested it out here:

fadeOut("hello",10000);
document.getElementById("hello").style.opacity = 1;
fadeOut("hello",10000);
document.getElementById("hello").style.opacity = 1;
fadeOut("hello",10000);
document.getElementById("hello").style.opacity = 1;

It would take it a long time to calculate and only when it finishes it will dump the result,
not showing it seamlessly, while calculating,
How can I resolve this?

  • 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-04T21:32:19+00:00Added an answer on June 4, 2026 at 9:32 pm

    You need to set timers, as, until your function is done and the event handler can run, the UI won’t be updated.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to fiddle around with this concept and I can't seem to get
In this fiddle i have a part of my form: http://jsfiddle.net/ZXSKH/55/ I am trying
http://jsfiddle.net/AndyMP/fVKDy/ This fiddle illustrates a problem I am trying to solve. The container DIV
I've looked around, and I'm trying to find an elegant solution to this, and
I'm a JSON noob and trying to fiddle around with the open table of
I am new to three20. I was trying to fiddle around with Launcher. I
please take a look at this fiddle : http://jsfiddle.net/cX47v/1 I am simply trying to
As you can see in this fiddle, http://jsfiddle.net/S8Bne/64/ , I am trying to draw
I am trying to fiddle around with Zend_Cache, so I added following code to
im really interested in airBNB search page, im trying to fiddle around with the

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.