:
1) dom, , DOM.
jQuery,
$(document).ready().
2) clearTimeout t , . t , timeout - .
3) timedCount() , JS eval, , . http://www.jslint.org. JS eval. , timedCount().
4) For another implementation, it really depends on how and when you want your function to be stopCount()called. In your implementation, it will never be called, as it continues to call the same function after an interval of 1 second.
The desired code may be something like
function timedCount()
{
t = setTimeout(function()
{
if ( can_clear_timeout() )
{
stopCount();
}
else
{
return timedCount();
}
}, 1000);
}
5) Another warning: you can not use global variables, such as timer_is_on, as this is contrary to standards.
source
share