Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

257
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!