javascript - Inline JS (OnMouseOver) - Repeat Something Until MouseOut Occurs -
is there way run given function every 10ms, considering limited running inline code (no external js files or tags)?
i can use:
<div onmouseover="functions here" onmouseout="functions here"> to more specific want move element left 50px every 10ms using marginleft, can not run externail functions or js libraries mentioned above.
i thinking of maybe incorporating in onmouseover setinterval(function, 10), don't see way of stopping when mouseout occurs.
i know can use jquery event handlers .on, these not option here since have externally loaded (not inline)
set global variable:
<div onmouseover="if (!window.intervalid) window.intervalid=setinterval(function() {/*your code*/}, 10);" onmouseout="clearinterval(window.intervalid); window.intervalid=null;">
Comments
Post a Comment