views:

177

answers:

4

Hi guys, I have a function called "go()" which needs to be called thrice on page load. Right now I have called it on the ready event of a div with class "nav". Can someone suggest how can I call the go function thrice. Adding go() calls one after other calls it only once.

$('.nav').ready(function() {
     go();
    });
+4  A: 

Even though you say this does not work, it should...

$('.nav').ready(function() {
     go();
     go();
     go();
    });

Update: If there is an error in your go() function, it might terminate execution before go() returns for the first time. Run in Firebug and see if you are getting any errors.

rikh
Thanks, there was an error in my function which made me look dumb on StackOverflow! Thanks for all the responses guys.
theraneman
+2  A: 
$('.nav').ready(function() {
     go();
     go();
     go();
    });

Should call it three times.

Martynnw
A: 

Like rikh sayd, you must be mistaken.

Please test that you can see three hello-s when you replace your go() function with something like this:

function go() {
  alert("hello");
}
Rene Saarsoo
+2  A: 

As other people have stated, placing the calls one-after-the-other should have called it three times. Perhaps there something that go() is doing that is not being done more than once due to how the function is called, etc. It might be helpful to take a closer look at go() - please post that code and/or explain why you need to call it 3 times.

Justin Ethier