Automatically close a banner | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Automatically close a banner

Hey Guys. I'm new in JavaScript. I have a banner in my website, the banner Id is #advt. I need a js code to close banner after a while. but I don't know how to use setTimeout to take action like display:none; for that banner Id. Pls help.

16th Feb 2018, 1:58 PM
Behnam
Behnam - avatar
2 Answers
+ 3
setTimeout(function() { $('#advt').fadeOut('fast'); }, 2000); // or var = document.getElementById("advt"); advt.style.display = "none";
16th Feb 2018, 2:40 PM
ihateonions
0
Thanks, but its doesn't work. Any suggestions?
16th Feb 2018, 11:08 PM
Behnam
Behnam - avatar