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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:51:05+00:00 2026-05-22T00:51:05+00:00

<style type=text/css> #box { background: red; width: 100px; height: 100px; color: #fff; line-height: 100px;

  • 0
<style type="text/css">
    #box { background: red; width: 100px; height: 100px; color: #fff; line-height: 100px; }
</style>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
    $(function() {

        $('a#clickMe').click(function(e) {
            e.preventDefault();
            $('#box').css('position', 'absolute').animate({
                'left' : '+=100px'
            }, function() {

                    if ($('#box').offset().left > $(document).width()) {
                        alert('that is far enough')
                    }

            });

        });
    });
</script>

<a href="" id="clickMe">Click Me</a>

<div id="box">I Move!</div>

I’m trying to alert “that is far enough” when the box reaches the end of the page. But the alert never shows.

EDIT

Never mind, figured it out. I had to use $(window).width() instead of $(document).width();

  • 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-22T00:51:06+00:00Added an answer on May 22, 2026 at 12:51 am

    Because moving the element to the left is expanding the width of the document.

    Try adding this css:

    #wrapper {
        width:100%;
        height:100%;
        overflow:hidden;
        position:relative;
        margin:0;
        padding:0;
    }
    #box{ 
        background:orange;
        top:0;left:0;
    }
    

    <div id="wrapper">
        <a href="" id="clickMe">Click Me</a>
    
        <div id="box">I Move!</div>
    </div>
    

    Example: http://jsfiddle.net/UhgM5/1/


    EDIT: Updated to make it FF compatible. Thanks to @Tomalak Geret’kal.

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

Sidebar

Related Questions

<html><head> <title></title> <meta http-equiv=Content-Type content=text/html; charset=UTF-8> <style type=text/css> .box {background:gray;border:3px solid black;float:left;} </style> </head>
I have the following javascript: css = document.createElement('style'); css.setAttribute('type', 'text/css'); css_data = document.createTextNode(''); css.appendChild(css_data);
<!DOCTYPE html> <html> <head> <title>Title</title> <meta http-equiv=content-type content=text/html; charset=utf-8> <style type=text/css> body { background:
/* Style 1 */ .myclass { background:#ff0; border:1px solid #ff0 } #myid { width:80px;
<head> <title>Overlay test</title> <meta http-equiv=Content-Type content=text/html; charset=iso-8859-1 /> <style type=text/css> #overlay { position: absolute;
Ok, I've got this code: <html> <head> <meta http-equiv=Content-Type content=text/html; charset=iso-8859-1> <script type=text/javascript href=https://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js></script>
Goal: Have first input box background-color change to green (on target.html) after redirecting. It
i have put in a css box colored red and for some reason the
I've got a stylesheet that will not, for whatever reason, apply list-style-type to a
What are the proper uses of: static_cast dynamic_cast const_cast reinterpret_cast (type)value (C-style cast) type(value)

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.