ajax学习笔记一:动态更改div位置
a small program ,in order to update the the position of a div use javascrpt , simulate to the tooltip.
just for memo
function Button1_onclick(elem)
{
var offsetx = elem["offsetLeft"];
var offsety = elem["offsetTop"];
while(elem)
{
offsetx += elem["offsetLeft"];
offsety += elem["offsetTop"];
elem = elem.offsetParent;
}
document.getElementById("tooltip").style.left=offsetx+"px";
document.getElementById("tooltip").style.top=offsety+"px";
}
{
var offsetx = elem["offsetLeft"];
var offsety = elem["offsetTop"];
while(elem)
{
offsetx += elem["offsetLeft"];
offsety += elem["offsetTop"];
elem = elem.offsetParent;
}
document.getElementById("tooltip").style.left=offsetx+"px";
document.getElementById("tooltip").style.top=offsety+"px";
}
technical support: http://xiexiaokui.cnblogs.com