javascript - onClick event bugged when used with setTimeout function -
i want disable onclick
event 1 second when user performs onclick
event on element id .flipper
. problem when call triggeronclick()
function, permanently disable onclick
event.
here code using
function triggeronclick(){ settimeout(function() { $(".flipper").off("click", triggeronclick); }, 1000); $(".flipper").on("click", triggeronclick); } $(".flipper").click(triggeronclick);
you're turning off after 1 second. , can crystal clear what's happening first, i'll put .off
@ top of function:
function triggeronclick(){ $(".flipper").off("click"); settimeout(function() { $(".flipper").on("click", triggeronclick); }, 1000); } $(".flipper").click(triggeronclick);
Comments
Post a Comment