setTimeout runs only once?

setTimeout should only run once. You’re looking for setInterval. var loop_handle = setInterval(slide, 3000); Also, the second argument should be a number, not a string. When the function call doesn’t require any arguments, it’s better to reference to the function instead of using a string. A string would be converted to a function. This function …

Read more

How to tell .hover() to wait?

This will make the second function wait 2 seconds (2000 milliseconds) before executing: $(‘.icon’).hover(function() { clearTimeout($(this).data(‘timeout’)); $(‘li.icon > ul’).slideDown(‘fast’); }, function() { var t = setTimeout(function() { $(‘li.icon > ul’).slideUp(‘fast’); }, 2000); $(this).data(‘timeout’, t); }); It also clears the timeout when the user hovers back in to avoid crazy behavior. This is not a very …

Read more