又有个问题,请大家帮忙。在线等,解决麻烦给分

wei977 2004-11-11 02:11:46
这断代码是返回bution的ID.我要删除Button1对象怎么搞啊。是不是del TR啊。请大家帮忙
<script language=javascript >
function getIndex(obj){

var tdObj=obj.parentNode.parentNode.parentNode
var allButton=tdObj.getElementsByTagName("button")
for(var i=0;i<allButton.length;i++){
if(allButton[i]==obj){
alert(i+1)
return
}
}



}
</script>

<table id="conyTableDown">
<tbody id="conyTableDown0">
<tr class="recBody" height="24px">
<td align="right" colspan="1">
<button ID="Button1" onclick=getIndex(this)> </button>
</td>
</tr>
<tr class="recBody" height="24px">
<td align="right" colspan="1">
<button ID="Button2" onclick=getIndex(this)> </button>
</td>
</tr>
<tr class="recBody" height="24px">
<td align="right" colspan="1">
<button ID="Button3" onclick=getIndex(this)> </button>
</td>
</tr>
</tbody>

<tbody id="conyTableDown1">
<tr class="recBody" height="24px">
<td align="right" colspan="1">
<button ID="Button4" onclick=getIndex(this)> </button>
</td>
</tr>
<tr class="recBody" height="24px">
<td align="right" colspan="1">
<button ID="Button5" onclick=getIndex(this)> </button>
</td>
</tr>
<tr class="recBody" height="24px">
<td align="right" colspan="1">
<button ID="Button5" onclick=getIndex(this)> </button>
</td>
</tr>

</tbody>

</table>
...全文
87 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wei977 2004-11-11
  • 打赏
  • 举报
回复
都谢谢大家咯,特别谢谢stone
emu_ston 2004-11-11
  • 打赏
  • 举报
回复
obj.parentNode.parentNode.parentNode.removeChild(obj.parentNode.parentNode);
呵呵
shyslysky 2004-11-11
  • 打赏
  • 举报
回复
<script language=javascript >
function removeBtn(obj){
obj.removeNode(true)
}
</script>

<button ID="Button3" onclick=getIndex(this);removeBtn(this)> </button>
meizz 2004-11-11
  • 打赏
  • 举报
回复
Button1.removeNode(true);
ttyp 2004-11-11
  • 打赏
  • 举报
回复
obj.parentNode.removeNode(obj)
tianch 2004-11-11
  • 打赏
  • 举报
回复
Button1.parentElement.innerHTML="";

87,996

社区成员

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

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