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
  • 44,076
  • 86
  • 209
  • 342

4 Answers4

7

Yes. Not a problem to do that.

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

Jonathon Bolster
  • 15,681
  • 3
  • 41
  • 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,015
  • 5
  • 44
  • 59
1

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

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

Pavan
  • 3,979
  • 1
  • 18
  • 22
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,046
  • 2
  • 26
  • 38