jquery - how show and hide div with time and click option to hide included? -


i have div display: none; want show hide in 5 seconds if in mean time user click on div should disappear once clicked. , seem can't both time disappear , click option.

here code.

$('#div').fadein(); $('#div').delay(5000).fadeout(); $('#div').click(function(){     $(this).fadeout(); }); 

if took out $('#div').delay(5000).fadeout(); won't disappear until click.

if took out $('#div').click(function(){ $(this).fadeout(); }); won't disappear when user click on it.

additional info

the thing if add $('#div').delay(5000).fadeout(); before or after click code. div wait 5 sec , div unclickable.

this should you're looking for.

$('#div').fadein(); timerid = settimeout(function(){     $('#div').fadeout(); }, 5000); $('#div').click(function(){     $(this).fadeout();     cleartimeout(timerid); }); 

Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -