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

181
Views
how to store a function so it works only after clicked and results stays after refreshing the page?

    function hd() {
        document.getElementById("Y").style.display = "none";
    }
body {
display:grid;
place-content: center;
height:100vh;
overflow:hidden;
}
<div id="Y">i will be hidden</div>
<br>
<button onclick="hd();">click me</button>


The important thing is to store the function so it works even user refreshes the page I tried to use cookies but it did not work by just calling the function

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

0

You can set a flag with localStorage and then check if this flag has already been set and call the function again at startup.

 function hd () { document.getElementById("Y").style.display = "none"; localStorage.setItem("hidden", "yes"); } if (localStorage.getItem("hidden")) { hd(); }
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!