What do you mean? Do you want it to hide #overlay automatically too? "How can I change my code so that it disconnects after a while?" If you want this automatically, do the following:
var hide = setTimeout(function () { $('#overlay').css('visibility', 'hidden'); }, 5000);
And keep in mind that setting visibility to hidden only hides it, but still takes up space. Setting display: none (hide ()) completely hides it.
Another thing is that you should not use id for this div. As you probably know, the identifier can be used only once, and it was said that you can never use your function for several lithiums with the same functionality. I would make it a class, and then:
$('.album').click(function () { $(this).children('.overlay').css('visibility', 'hidden'); });
That way, it will work on everyone that has an overlay div.
source share