Harry Pen Harry Pen - 1 year ago 85
HTML Question

How to show/hide content

I have a page where I would like two buttons which when one is clicked, displays hello, and when the other one is clicked would hide the "hello" message and then display "goodbye". I know this needs to be done in javascript but I am not good with javascript.

Answer Source

Check this snippet

<p id="msg"></p>

<button onclick="helloFunction()">Say Hello</button>
<button onclick="byeFunction()">Wave Goodbye</button>

function helloFunction() {
    document.getElementById("msg").innerHTML = "Hello";
  function byeFunction() {
    document.getElementById("msg").innerHTML = "Goodbye";


Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download