I need to find a solution where you open a layer to place advertising that closes automatically if you do not do anything.
Is there any script you can recommend?
Can you help me with this question?
I need to find a solution where you open a layer to place advertising that closes automatically if you do not do anything.
Is there any script you can recommend?
Can you help me with this question?
You can use the setTimeout
function. Here's an example:
jQuery(function(){
var itv = window.setTimeout(function(){
jQuery("div.publicidade").fadeOut("fast", function(){ //ocultando a div da pagina com um efeito de fade
jQuery("div.publicidade").remove(); //eliminando a div
window.clearInterval(itv);
});
}, 3000); // delay de 3 segundos para executar a ação
});
div.publicidade{position:absolute; width: 200px; height: 200px; background: #efefef; border: 1px solid #ccc; top:100px; left: 100px;}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script><divclass="publicidade"></div>