I’m a jquery novice trying to write my first app here and one thing I’ve been trying to figure out is how to use the .delay() method if what I want to delay is the method of an object.
So for example, I have something like this:
dice = new Dice("#die1", "#die2");
dice.roll();
But I want there to be a delay before the roll() function is actually invoked. How would I do that?
I figured using jquery would be easier than pure javascript because I know that using setTimout() is tricky to use with your own methods.
There is nothing tricky or dangerous about
setTimeoutand it’s likely the most appropriate approach here. It’s specifically designed to execute functions after a given time has expired.For example here’s a 1 second delay