How to show a button, when clicking on another button?

javascript function button onclick

23 观看


1 作者的声誉

For example, if we have btn 1 and btn 2.

Is it possible (with the onclick event) to click on btn 1, and then btn 2 appears?

作者: Alex Hristov 的来源 发布者: 2017 年 12 月 27 日

回应 (1)


6024 作者的声誉


Any element, including button elements, can have events set which trigger styling properties of other elements to change.

An Example:

let get = document.querySelector.bind(document),
btn1 = get("#btn1"), btn2 = get("#btn2");

btn1.addEventListener("click", function() { = "initial";
.hidden {
display: none;
<button id="btn1">Click Me</button>

<button id="btn2" class="hidden" >I'm a button</button>

作者: zfrisch 发布者: 27.12.2017 04:37