Well, it looks like you are declaring interverID locally in an anonymous function from your .ready() handler. I really wonder why you don't encounter a Reference error in your click event handler, since the intervalID cannot be known there.
You need to make sure that this variable is accessible and has a common context for both functions. The easiest way to do this is to create an anonymous self-starting method around your script and declare this variable out of scope.
(function _myPrivateContext($, window, document, undefined) { var intervalID = null; $(document).ready(function() { intervalID = setInterval(rotate, 5000); }); $('a').click(function(){ clearInterval(intervalID); intervalID = setInterval(rotate, 5000); }); }(jQuery, window, document));
source share