+ 1

Can someone help?

I'm trying to make hide and show buttons that I can click to hide and show the text. I've completed the hide button, but I need help with show. I want show to reset the output so it shows the text again. Is there code for this? If so, I would love to know it. https://code.sololearn.com/WNqR9cHEhJV4/?ref=app

13th Jan 2018, 5:55 PM
jacksonofgames 28
jacksonofgames 28 - avatar
3 Answers
+ 4
Or like this: function hide() { var header = document.getElementById("header"); header.style.display = "none"; } function show() { var header = document.getElementById("header"); header.style.display = "block"; }
13th Jan 2018, 6:20 PM
Claude Dumont
Claude Dumont - avatar
+ 1
You could make header variable global, for example: var header; function hide() { var body = document.getElementById("body"); header = document.getElementById("header"); body.removeChild(header); } function show() { var body = document.getElementById("body"); if(body.firstChild) body.insertBefore(header,body.firstChild); else body.appendChild(header); }
13th Jan 2018, 6:10 PM
Dmitry Voronyuk
Dmitry Voronyuk - avatar
+ 1
Thank you guys
13th Jan 2018, 8:22 PM
jacksonofgames 28
jacksonofgames 28 - avatar