Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Doing something wrong, moving a div by pixels + other div height

    Could someone please explain what I'm doing wrong here. I'm trying to move a division to a specific distance from the top plus the height of another division.

    This moves the div far more than 50 pixels.

    Thanks for your help.

    <html>
    <head>
    <title></title>
    <style>
    #myDiv, #MoveThis
    {border-style: solid; padding: 10px; position: absolute;}

    #myDiv
    {top: 50px;
    left: 0px}

    #MoveThis
    {top: 150px;
    left: 0px}
    </style>
    <script>
    function AddHeight(id,pixels) {
    var DivHeight = document.getElementById('myDiv').offsetHeight;
    document.getElementById(id).style.top = DivHeight+pixels;
    }
    </script>
    </head>
    <body>
    <a href="#" onClick="AddHeight('MoveThis','50')">Move it</a>
    <div id="myDiv">
    content<br>
    content<br>
    content<br>
    content
    </div>
    <div id="MoveThis">
    content<br>
    content<br>
    content<br>
    content
    </div>
    </body>
    </html>
    Last edited by Graeme Hackston; 07-11-2002 at 01:14 AM.

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Posts
    1,404
    Thanks
    2
    Thanked 32 Times in 32 Posts
    Hi Graeme...

    <a href="#" onClick="AddHeight('MoveThis',50)">Move it</a>

    Concatention is fine, in its place....

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    623
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Cool, thanks much Adios.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •