0

I am answering my own question in the hopes it will solve someone else's headache:

I could not get the following code to work:

        function givePosition(){
            var place = $('#two').position();
            console.log(place);
        }

        window.setInterval(givePosition(), 50);
  • Unfortunately this is a widely known thing and a duplicate of a duplicate of a duplicate. – Sterling Archer Aug 25 '14 at 18:48
  • The master canonical answer seems to be [Why is my function call that should be scheduled by setTimeout executed immediately?](https://stackoverflow.com/questions/2037203/why-is-my-function-call-that-should-be-scheduled-by-settimeout-executed-immediat), but the duplicate at [setTimeout ignores timeout? (Fires immediately)](https://stackoverflow.com/questions/4120781/settimeout-ignores-timeout-fires-immediately) applied more directly to this question. – apsillers Aug 25 '14 at 18:51

1 Answers1

0

The solution to my problem was to give the function name as a parameter without parentheses, like so:

window.setInterval(functionName, 50);

instead of:

window.setInterval(functionName(), 50)