Web Analytics Made Easy -
StatCounter Doing something wrong, moving a div by pixels + other div height - CodingForum

Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new 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; Jul 10, 2002, 08:14 PM.

  • #2
    Hi Graeme...

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

    Concatention is fine, in its place....

    Comment


    • #3
      Cool, thanks much Adios.

      Comment

      Working...
      X