//获取元素的绝对位置X function Position(id) { var x = id.offsetLeft; while(id = id.offsetParent) { x += id.offsetLeft; } return x; } function $(id) { return document.getElementById(id) }