javascript - Replace "onClick" with "after x seconds" -
this question has answer here:
<div id="c" onclick="func()"></div> this execute funct() when user click. want execute func() automatically after 10 seconds. somethink this:
<div id="c" after10seconds="func()"></div>
write logic. use flag , timeout on page load:
var hascalledfunc = false; settimeout(function() { if (hascalledfunc == false) func(); }, 10000); function callfunc() { if (hascalledfunc == false) func(); } function func() { hascalledfunc = true; //..rest of func } and html:
<div id="c" onclick="callfunc()"></div> or, in func
var hascalledfunc = false; function func() { if (hascalledfunc) return; else hascalledfunc = true //rest of func } settimeout(func, 10000);
Comments
Post a Comment