急,在线等待,定位问题!

cici_sun 2002-06-20 12:34:31
<form id = "form1">
<table..
<button id = "button1" style = "width:20px;height:20px" >...
<button id = "button2" style = "width:20px;height:20px" >...
要在javascript定义的函数中确定button1的绝对位置怎么做?
...全文
40 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
seabell 2002-06-20
  • 打赏
  • 举报
回复
<form id = "form1">
<table><tr><td>
<button id = "button1" style = "position: absolute;width:20px;height:20px;top:400px;left:200px" > <button id = "button2" style = "width:20px;height:20px" >
</td></tr></table></form>
meizz 2002-06-20
  • 打赏
  • 举报
回复
<script language="Javascript"><!--
function getxy(tt){alert("top="+tt.offsetTop+" and left="+tt.offsetLeft);}
// --></script>

 <input type=button name=input1 value=input1 onclick=getxy(this)>

<script>getxy(document.all.input1)</script>
cici_sun 2002-06-20
  • 打赏
  • 举报
回复
哦,可能我没有说清楚,button只有width和height,它在页面中自己取定了位置,我要取到当前的button1的绝对位置,怎么取?这里有n个button,他们的id是由变量j 决定的。

87,994

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧