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

259
Visualizações
How to make a hidden display apeear again

I'm using the follow code to make the display appear:

<div id="create_phase{{ forloop.counter }}" class="w3-modal" onclick="this.style.display='visible'">

and the follow code to hidden display:

<a onclick="document.getElementById('create_phase{{ forloop.counter }}').style.visibility = 'hidden'">X</a>

It works fine, but i can't make display appear again after hidden it.

Any suggestions?

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

0

Like Laif said in the comments, spaces in your IDs are not a good idea. I think the best solution is to use IDs with proper naming conventions that the DOM plays well with.

But a possible (hacky) solution could be prefacing the spaces in your getElementById call with \ to properly escape them.

Here's a CodePen: https://codepen.io/milofultz/pen/KKvGJbJ

about 4 years ago · Juan Pablo Isaza Relatório

0

You need to give your IDs proper names (cannot have spaces), as it is now, your div actually has 3 separate IDs.

and you need to change .style.visibility = 'visible', to .style.visibility = 'hidden' as your original code is not modifying the same style.

<div id="ele1" class="w3-modal" onclick="this.style.visibility='hidden'">
  test
</div>
  <a onclick="document.getElementById('ele1').style.visibility = 'visible'">X</a>

Notice, in this snippet I had to reverse the way you were trying to hide and show content in the original, because a hidden element is not clickable, if you want to be able to click it. I would use opacity instead, like this:

<div id="ele1" class="w3-modal" onclick="this.style.opacity=100">
  test
</div>
  <a onclick="document.getElementById('ele1').style.opacity=0">X</a>

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