...

View Full Version : Doing something wrong, moving a div by pixels + other div height



Graeme Hackston
07-11-2002, 01:07 AM
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>

adios
07-11-2002, 01:18 AM
Hi Graeme...

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

Concatention is fine, in its place....

Graeme Hackston
07-11-2002, 01:24 AM
Cool, thanks much Adios.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum