我试图隐藏一个按钮后,onclick事件与JavaScript。我的按钮位于页面的顶部,所以当有人点击它时,会显示内容,但是按钮仍然在页面上。我在想,在用户点击按钮后,我是否可以隐藏它。
你对怎么做有什么建议吗?
下面是我使用的代码:
function showDiv() {
document.getElementById('menuDiv').style.display = "block";
}
#menuDiv{
display: none;
}
<div class="text-center">
<button onclick="showDiv()" class="btn btn-light"><img src="images/cartoon-cookie.png" alt="Cookie"
style="height:100px;">Yes, I want to see the menu</button>
</div>
<div id="menuDiv">
<!-- here is the content that is revealed after the on click event -->
</div>
发布于 2020-07-03 17:15:08
可以使用style属性visibility
隐藏按钮,并将其设置为hidden
。或者,如果隐藏还不够,可以从DOM中删除按钮。
https://stackoverflow.com/questions/62719921
复制相似问题