html - how to create a button that when I click it appears another

-2

I want to create a button that when I click on it perform an action eg open a website and together a button appears below.

type, to access the site click this button and after the person clicks on it open a website and another button appears below.

Another example: To download click this button and go to our website first and after the person clicks and access the site the download button will appear.

Help me ...

    
asked by anonymous 08.01.2018 / 23:41

1 answer

0

I imagine this solution is right for you:

HTML

<div>
  <button class = "b1">
    Clique-me!
  </button>

  <button class = "b2" style = "display: none;">
    Outro botão!
  </button>
</div>

JavaScript

var button = document.querySelector(".b1");
var button2 = document.querySelector(".b2");

button.onclick = function() {
 window.open('www.google.com', '_blank');
 button2.style.display = "block";
}

When you click the b1 button, the function linked to onclick will open a new tab and change the display: none to display: block of the second button, class b2 .

JsFiddle: link

    
09.01.2018 / 00:38