Skip to content
Advertisement

Problem viewing a div with a simple function

I have a problem I would say stupid with html and javascript, a simple function that should make me visible and invisible a div crashes the html making it empty!

<button onclick="open()">Modifica</button>

js:

var x = document.getElementById ("joseph");
   if (x.hidden == false) {
     x.hidden = true;
   } else {
     x.hidden = false;
}

before: enter image description here

after: enter image description here

Advertisement

Answer

You don’t have to write pre-defined methods. It works same for all other tech stacks such as Mysql, PHP, etc.

Recommend using opens, not open if you insist to use the open word.

<button onclick="opens()">Modifica</button>
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement