Search code examples
javascriptjqueryfadein

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


Solution

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

    Did work - nevermind then.