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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:48:00+00:00 2026-06-17T05:48:00+00:00

var fade = 1; function fadeit() { if (fade < 4500) fade++ else fade

  • 0
var fade = 1;

function fadeit() {
    if (fade < 4500) 
        fade++
    else 
        fade = 1
    setTimeout("fadeit()", 100)
}

function fader() {
    fadeit()
    if (fade < 3500) 
        document.getElementById("showone").style.opacity = "0.4";
    else if (fade < 500) 
        document.getElementById("showone").style.opacity = "0.1";
    else 
        document.getElementById("showone").style.opacity = "1.0";
}

I am trying to get this code to work so that it will fade the image at different times.

  • 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-17T05:48:02+00:00Added an answer on June 17, 2026 at 5:48 am

    You need to actually do the fading on each call to fadeit. All you’re doing is running up the count. Also, the logic of your if...else if...else was wrong. The first condition will always be true whenever the second condition is true, so the second branch will never be taken. I’ve rewritten it here:

    var fade = 1;
    
    function fadeit() {
        if (fade < 4500) {
            fade++
        } else {
            fade = 1
        }
        doFade();
        setTimeout(fadeit, 100)
    }
    
    function fader() {
        fadeit()
    }
    
    function doFade() {
        if (fade < 500) 
            document.getElementById("showone").style.opacity = "0.1";
        else if (fade < 3500) 
            document.getElementById("showone").style.opacity = "0.4";
        else 
            document.getElementById("showone").style.opacity = "1.0";
    }
    

    Note that this will continuously cycle through the fade-in (which is what your original code was trying to do). If you want to fade-in once and be done with it, you could rewrite it as:

    var fade = 1;
    
    function fadeit() {
        if (fade < 4500) {
            fade++
            doFade();
            setTimeout(fadeit, 100)
        }
    }
    
    function fader() {
        fade = 1;
        fadeit()
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

var search= document.getElementById('appMenu').value document.location.href= '${createLink(controller: 'application' , action:'ajaxAppSearch', params: ['query': search])}' The element appMenu
var hyp = document.createElement(a); //hyp.style.cssText='cursor:pointer'; hyp.onclick=RemoveDv(' + divid + ');; hyp.innerHTML = Remove; I
What is wrong in this code? function FloatMenu() { var scrollAmount = $(document).scrollTop(); var
var ref1 = new Firebase(http://gamma.firebase.com/myuser/123,456); ref1.set(123,456); var on1 = ref1.on(value, function(snapshot) { console.log(snapshot.val()); });
var Foo = Foo || {}; Foo.Controller = (function ($) { var $page =
var JavascriptHelper = Backbone.Model.extend(JavascriptHelper, {}, // never initialized as an instance { myFn: function()
var a = document.createElement('div'); a.id = myDiv; and var a = document.createElement('div').id = myDiv;
This is how I currently do it: function switchcontent(wait){ //fade out image1 $('#feature-img img:first-child,
I have written one custom paremeterized jquery function for fadein and fade out. That
I have the following code for a fade animation in Javascript: var ticks =

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.