I can't get the .delay
method working in jQuery:
$.delay(3000); // not working
$(queue).delay(3000); // not working
I'm using a while loop to wait until an uncontrolled changing value is greater than or equal to another and I can't find any way to hault execution for X seconds.
$.delay is used to delay animations in a queue, not halt execution.
Instead of using a while loop, you need to recursively call a method that performs the check every second using
setTimeout
:JavaScript
setTimeout
is a very good solution:The
delay
function in jQuery is mostly used for delaying animations in a jQuery animation queue.