3

Possible Duplicate:
jQuery - is it bad to have multiple $(document).ready(function() {});
Can you have multiple $(document).ready(function() sections?

I would like to know if it's allowed to have multiple instances of:

$(document).ready(function(){

})

on one of several pages ?

Community
  • 1
  • 1
Satch3000
  • 47,356
  • 86
  • 216
  • 346

4 Answers4

7

Yes. Not a problem to do that.

Just to extend on that: http://jsfiddle.net/CBCrZ/

Jonathon Bolster
  • 15,811
  • 3
  • 43
  • 46
2

not sure what you mean by on several pages. But yes you can have multiples of document.ready. They will get called in the order you add them.

ek_ny
  • 10,153
  • 6
  • 47
  • 60
1

Yes. You can use it more than once. see this post

http://docs.jquery.com/Tutorials:Multiple_$(document).ready()

Pavan
  • 4,209
  • 1
  • 22
  • 25
1

Is fine to have more than one. The call order is the same as the definition order: first-come first-served.

See also here: second $(document).ready event jQuery

Community
  • 1
  • 1
mamoo
  • 8,156
  • 2
  • 28
  • 38