here nooby question answer searched way long while not finding anything. i'm not used javascript other programming languages so, how work if want checked for?
here code:
var test = 0; $( ".test_div" ).click(function() { test = 1; });
now if want check if variable 1, constantly, do? tried didn't work:
if (test == 1) { }
thanks!
you searching done in interval
following you:
var test = 0; var interval; function check_test() { if( test == 1 ){ clearinterval( interval ); console.log( "test 1 now!" ); } } interval = window.setinterval( check_test, 1000 );
the 1000
in milliseconds, 1000 ms = 1 second. call check_test()
every 1sec.
you window.settimeout
in simmiliar way, 1 time. call inside function again , if want stop it, stop calling it.
Comments
Post a Comment