Link to home
Start Free TrialLog in
Avatar of Whing Dela Cruz
Whing Dela CruzFlag for Anguilla

asked on

Diminish Pop-up in 3 seconds

Hi Expert, I have attached a sample pop-up here where I want to put some codes that would enable the pop-up diminish in 3 seconds. Is this possible? Any help please.

<script>
function myFunction() {
    var popup = document.getElementById("myPopup");
    popup.classList.toggle("show");
}
</script>
Avatar of David Johnson, CD
David Johnson, CD
Flag of Canada image

<script>
var delayMIllis=3000; //3 seconds
function myFunction() {
    var popup = document.getElementById("myPopup");
    popup.classList.toggle("show");
etTimeout(function() {
popup.classList.visibility: hidden;
}, delayMillis);
</script> 

Open in new window

Avatar of Whing Dela Cruz

ASKER

Hi David Johnson,
I tried it but it doesn't work. A popup will no longer appear as I tried to add this, "}" at the end part of the code as i felt lacking on the codes but result is still the same.
Use the setTimeout function for it.

<script>
function myFunction() {
    var popup = document.getElementById("myPopup");
    popup.style.display = "block"; // Or whatever way you want to show it.
    setTimeout(function() {
        popup.style.display = "none"; //Or whatever way you want to hide it.
    }, 3000);
</script> 

Open in new window

Hello Rawat,
Still won't work, pop-up will no longer appear upon implementing the codes..
ASKER CERTIFIED SOLUTION
Avatar of Ishaan Rawat
Ishaan Rawat
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I added "}" at the end part of the codes, now its working. Thank you very much sir!
Thank you sir More power and God bless!