HTML 按钮点击后消失:简单代码示例
<!DOCTYPE html>
<html>
<head>
<title>按钮点击后消失</title>
<style>
#myButton {
display: block;
margin: 50px auto;
padding: 10px 20px;
font-size: 16px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<button id='myButton' onclick='this.style.display='none''>点击我消失</button>
</body>
</html>
<p>说明:当按钮被点击时,使用 JavaScript 的内联样式将按钮的 display 属性设置为 none,使其消失。</p>
原文地址: https://www.cveoy.top/t/topic/nnui 著作权归作者所有。请勿转载和采集!