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

87
Views
fadeIn Element just once in a session

I have a function:

function loremIpsum() {
$('.element').fadeIn()
}

to show a hidden Element - The issue is, that a user can go back with a second button and call the loremIpsum() function again, but the function should be called just once. Can I limit that in someway ? I couldn't find a Post for that here.

I tried this:

function loremIpsum() {
    var executed = false;
    return function() {
        if (!executed) {
            executed = true;
            $('.element').fadeOut()

        }
    }
}

But that didn't work

about 4 years ago · Santiago Gelvez
2 answers
Answer question

0

You can use sessionStorage to keep track of executed boolean value for the session.

function loremIpsum() {
    sessionStorage.setItem('executed', true);
    $('.element').fadeIn();
}

And in the caller, you can check:

if (!(sessionStorage.getItem('executed') === "true")) { //since sessionStorage stores items as strings
    loremIpsum();
}
about 4 years ago · Santiago Gelvez Report

0

function loremIpsum() {
    loremIpsum= function() {};
    $('.element').fadeIn()
}

Did work - nevermind then.

about 4 years ago · Santiago Gelvez 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!