我的代码如下,我想要的效果是点击任一按钮“1”后该按钮就消失,现在的代码只能让最后一个消失,忘指教
<table>
<tr>
<td><button value="gg" id ="gg" onclick="presentQ(this)"></button>
</td>
</tr>
</table> <script>
function presentQ(e){
e.parentNode.innerHTML += '<button id="be" value="be" onclick="hideButtonQ()">1</button>';
}function hideButtonQ(){
document.getElementById("be").style.display="none";
} </script>
<table>
<tr>
<td><button value="gg" id ="gg" onclick="presentQ(this)"></button>
</td>
</tr>
</table> <script>
function presentQ(e){
e.parentNode.innerHTML += '<button id="be" value="be" onclick="hideButtonQ()">1</button>';
}function hideButtonQ(){
document.getElementById("be").style.display="none";
} </script>
visibility="hidden"
都可以
<head>
<script>
hide = function(obj){
obj.style.visibility="hidden";
}
</script>
</head><body>
<input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/><input type="button" onclick="hide(this)" value="按钮"/><br/>
</body>
<html>