简体   繁体   English

单击另一个按钮时如何显示一个按钮?

[英]How to show a button, when clicking on another button?

For example, if we have btn 1 and btn 2. 例如,如果我们有btn 1和btn 2。

Is it possible (with the onclick event) to click on btn 1, and then btn 2 appears? 是否可以(通过onclick事件)单击btn 1,然后出现btn 2?

Yes . 是的

Any element, including button elements, can have events set which trigger styling properties of other elements to change. 任何元素(包括button元素)都可以设置事件,以触发其他元素的样式属性更改。

An Example: 一个例子:

 let get = document.querySelector.bind(document), btn1 = get("#btn1"), btn2 = get("#btn2"); btn1.addEventListener("click", function() { btn2.style.display = "initial"; }); 
 .hidden { display: none; } 
 <button id="btn1">Click Me</button> <button id="btn2" class="hidden" >I'm a button</button> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将样式添加到单击另一个按钮时创建的按钮? - How to add styles to a button that is created when clicking another button? 在 React 中单击另一个组件中的按钮后如何显示 Modal? - How to show Modal after clicking a button in another component in React? 如何通过使用javascript单击按钮来在另一个DIV中显示所选图像? - How to show selected image in another DIV by clicking on a button using javascript? 单击按钮或单选按钮时如何显示组件 - How to Show Components on clicking on button or Radio Button 显示一个div并隐藏另一个单击的按钮 - Show a div and hide another clicking a button 如何通过单击另一个按钮使一个按钮可见? - How to make a button visible by clicking another button? 单击另一个旨在显示/隐藏图层的按钮时,在Adobe PDF中隐藏/显示按钮的代码是什么? - What is the code to hide/show a button in Adobe PDF when clicking another button that's purpose is to shows/hides a layer? 单击同一个按钮时如何显示或隐藏div? - How to show or hide a div when clicking on the same button? 使用Reactjs单击显示按钮时如何渲染滤过国家? - How to render filitered countries when clicking the show button using Reactjs? css - 单击显示更多按钮时如何使用缓入 - css - how to use ease-in when clicking show more button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM