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

Asked

Viewed 2,616 times

-2

want to create a button that when I click on it perform an action for example open a site and together appear a button below.

type,to access the site click on that button and after the person click on it open a site and appear another button below.

another example: To download click this button and access our website first and after the person clicks and access the site appear the download button.

Help me...

  • You can use an onclick (Javascript) function to manipulate the button display, which you want to display by clicking the other

1 answer

0

I imagine this solution is appropriate 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";
}

By clicking the button b1, the function attached to the onclick will open a new tab and change the display: none for display: block second button, class button b2.

Jsfiddle: https://jsfiddle.net/xuuj2qv4/

  • it is possible to add javascript code in blogger html?

  • I can’t get html to work if I copy the html code and it won’t work

  • I know it’s possible, I just don’t know how exactly. HTML needs Javascript to work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.