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

  • Home
  • SEARCH
  • 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 8374711
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:58:59+00:00 2026-06-09T14:58:59+00:00

Help! I’ve no idea what’s going wrong here, I’m following along a tutorial video

  • 0

Help! I’ve no idea what’s going wrong here, I’m following along a tutorial video from Tuts+ The code is exact, yet the blue box is not animating to the left.

When I put an alert inside of the moveBox function, I see in the console the alert firing off the same message over and over again.

Here is my test link:

> Trying to animation a blue box left using Javascript <

Here is a screenshot from the video:

enter image description here

Here is my code:

(function() {

var speed   = 10,       
    moveBox = function() {
        var el = document.getElementById("box"),
            i = 0,
            left   = el.offsetLeft,
            moveBy = 3;
            //console.log("moveBox executed " +(i+1)+ " times");

            el.style.left = left + moveBy + "px";

        if (left > 399) {
            clearTimeout(timer);
        }
    };

var timer = setInterval(moveBox, speed);

}());

HTML:

<!DOCTYPE html>

<head>
<meta charset="utf-8">
<title>JavaScript 101 : Window Object</title>
<style>
    #box {
        position: abosolute;
        height: 100px;
        left: 50px;
        top: 50px;
        width: 100px;
        background-color: Blue;
    }
</style>
</head>

<body>

<div id="box"></div>
<script src="js/animation.js"></script>

  • 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-09T14:59:00+00:00Added an answer on June 9, 2026 at 2:59 pm

    You mispelled “absolute” in your positioning:

    #box {
        position: absolute;   // Your mispelling here
        height: 100px;
        left: 50px;
        top: 50px;
        width: 100px;
        background-color: Blue;
    }
    

    Once I fixed that, it worked fine.

    A word of advice — put a second condition in loops like this so that if the animation fails for some reason you don’t end up in an infinite loop. For example, you might have done this:

    (function() {
    
    var maxTimes = 1000;
    var loopTimes = 0;
    var speed = 10,       
    moveBox = function() {
        var el = document.getElementById("box"),
            i = 0,
            left   = el.offsetLeft,
            moveBy = 3;
            //console.log("moveBox executed " +(i+1)+ " times");
    
         el.style.left = left + moveBy + "px";
    
         loopTimes += 1;
         if (left > 399 || loopTimes > maxTimes) {
             clearTimeout(timer);
         }
    };
    
    var timer = setInterval(moveBox, speed);
    
    }());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Help me translate following block of the Haskell code. The run function produces text
Help from the SQL Gods Required Table 1 - DistinctQuotes This tables holds information
HELP......Just moved to C# from vb and Im really lost with this. var ldapmembershipUser
Help for this specific server side php code I don't have any knowledge of
Help me with this part of code: class Ooo attr_accessor :class_array end def func(ctx)
help me please i'm having the following issue: I'm trying to read a XML
Help- Any idea what would cause sharepoint's doc library's tree view navigation to break?
Help me understand this piece of code - After the first iteration the value
Help please! my first program in objective c. Followed a tutorial word for word
Help me settle an argument here. Is this: SqlCommand cmd = new SqlCommand( sql

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.