javascript - Div Close and open with delay function of jQuery -


i creating advertisement box, show here http://jsfiddle.net/tfexy/1/ ,

when user click on button 'show ads', 'addbox' open , can close 'addbox' div clicking 'close' button . work properly.

but when user click on close button of 'addbox' before 10 second (say after 3 sec), , click on 'show ads' button , 'addbox' doesn't open instantly . how can make 'addbox' visible instantly .

here html portion,

<div id ="addbox" style ="display:none; height:200px; width:200p x; background:red">     advertisment popup     <a id ="close" syle="float:right;">close</a> </div>  <a id="showads">show ads</a> 

and jquery portion :

$('#showads').click(function(){ $('#addbox').show(100).delay(10000).hide(100); })  $('#close').click(function(){ $('#addbox').hide(); }) 

use stop()..

 $('#clickme').click(function () {    $('#addbox').show(100).delay(6000).hide(100);  })  $('#close').click(function () {     $('#addbox').stop().hide(); }) 

however... have native settimeout function too. can cleartimeout using

cleartimeout(); 

fiddle here.


Comments