View Full Version : movediv to X,Y?
mattover-matter
04-18-2003, 07:53 AM
I've looked all over in tutorials, but could not find this. How can I move something similar to this:
document.getElementById("div")moveto(20, document.getElementById("imageid").style.left
so it would be 20 px from the top and the left would be aligned with the left of "imageid". Am I confusing you?
Skyzyx
04-18-2003, 08:25 AM
Well, you'd probably have to write correct syntax for it to work.
Assuming your DIV container has an ID of "div", the following should work:
var left = parseInt(document.getElementById("imageid").style.left.split('px')[0]);
document.getElementById("div").moveTo(20, left);
Granted, this is off the top of my head. The ...style.left may return a value in pixels, not just numbers. This strips off the "px" and parses it as an integer (which is what the script requires for input), assigns it to a variable, and then the variable is used as a parameter to the moveTo function.
mattover-matter
04-18-2003, 08:35 AM
I'm sorry. Just figured it out :p
document.getElementById('divname').style.left = document.getElementById('anotherid').style.pixelLeft
document.getElementById('divname').style.top = '5px'
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.