日期:2014-05-16  浏览次数:20345 次

关于怎么取控件的XY坐标!
<script>
function   showXY(obj){
alert( "X: "+obj.style.top+ "\n\nY: "+obj.style.left)
}
</script>
<input   type= "text "   onClick= "showXY(this) "> <input   type= "text "   onClick= "showXY(this) "> <br>
<input   type= "text "   onClick= "showXY(this) ">

------解决方案--------------------
<script>
function showXY(obj){
alert( "X: "+obj.offsetTop+ "\n\nY: "+obj.offsetLeft);
}
</script>
<input type= "text " onClick= "showXY(this) "> <input type= "text " onClick= "showXY(this) "> <br>
<input type= "text " onClick= "showXY(this) ">