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

141
Views
how to hide div for page load and then use a show/hide function as normal

Im trying to use the hide/show function to show an image when "<div" is clicked on. When I load onto the page for the first time, the image has already loaded onto the screen. I would like the image to be hidden on page load, allowing the image to then be revealed when the is clicked.

function active01() {
  var x = document.getElementById("img01");
  if (x.style.display === "none") {
    x.style.display = "block";
  } else {
    x.style.display = "none";
  }
}
#img01 {
  width: 800px;
  padding-left: 30px;
  display: none;
}
<div onclick="active01()" id="line01"> Exhibition_Design_The_Telephone_book_001....................2009-001</div><br>
<img id="img01" src="images/01 Exhibition design.jpg" alt="Exhibition_Design_The_Telephone_book_001....................2009-001"><br>

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

function myFunction() {
  var x = document.getElementById("myDIV");      
  if (x.style.display === "block") {
    x.style.display = "none";
  } else {
    x.style.display = "block";
  }
}
#myDIV {
  width: 100%;
  padding: 50px 0;
  text-align: center;
  background-color: lightblue;
  display: none;
  margin-top: 20px;
}
<button onclick="myFunction()">Try it</button>

<div id="myDIV">
This is my DIV element.
</div>

Check this example

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!