Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

125
Visualizações
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

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

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>
about 4 years ago · Juan Pablo Isaza Relatório

0

You've hit a variation of this problem.

When searching for a variable named open the browser finds document.open before it finds your open function.

document.open opens a new document for writing (with document.write) which erases the existing document.

window.open is also predefined, so making a new global function with that name is not advised.

As with the linked question: Use addEventListener instead of onclick attributes.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda