62,041
社区成员
发帖
与我相关
我的任务
分享
function CPos(x, y) {
this.x = x;
this.y = y;
}
function CreateDiv(obj) {
var target = obj;
var pos = new CPos(target.offsetLeft, target.offsetTop);
var target = target.offsetParent;
while (target) {
pos.x += target.offsetLeft;
pos.y += target.offsetTop;
target = target.offsetParent
}
var box = document.createElement("div");
box.style.backgroundColor = "white";
box.style.position = "absolute";
box.id = "auto";
box.style.posLeft = pos.x;
box.style.posTop = pos.y + obj.clientHeight + 5;
box.style.width = obj.clientWidth;
box.style.height = obj.clientHeight;
document.body.appendChild(box);
}