javascript - Call function again only after it finish executing -
i have function gets called every time enter key pressed. need make function not called if press enter key again, if , when function has not finish executing yet. when function has finished executing, called again if press enter key again. how in jquery, or javascript?
onkeydown = 'if(event.keycode==13) somefunction()' function somefunction() { //some codes //some settimeouts }
simply set boolean when done , check before executing function.
onkeydown = 'if(event.keycode==13) { if (!finished){somefunction();}' var finished = false; function somefunction() { finished = false //some codes //some settimeouts finished = true; }
though, luis points out, javascript single threaded , shouldn't running problems describe unless not understanding problem fully.
Comments
Post a Comment