setinterval - Call JavaScript function after 1 second One Time -


i have managed make div hide on click after 400 milliseconds using setinterval function. issue runs continually, need function execute once. after quick search discovered setinterval can stopped clearinterval. using incorrectly? closeanimation function being executed on click. modelled code after code on page: http://www.w3schools.com/jsref/met_win_setinterval.asp

function closeanimation() {     setinterval(function(){hide()}, 400);     clearinterval(stopanimation); }  var stopanimation = setinterval({hide()}, 400);  

if needs run once can use settimeout

settimeout(function () {   //do once }, 1000); 

Comments

Popular posts from this blog

php - render data via PDO::FETCH_FUNC vs loop -

c++ - OpenCV Error: Assertion failed <scn == 3 ::scn == 4> in unknown function, -

The canvas has been tainted by cross-origin data in chrome only -