views:

16

answers:

1

does jquery support multiples of

$(document).ready(function() {});

ie. can i make a few of these on the same page and they will all be executed? or does the newest one overwrite the last?

+4  A: 

Yes you can bind multiple, you can bind as many as you want, like other event handlers, they'll execute in the order they were bound.

None will be overwritten, additionally if the document is already "ready", it'll execute immediately.

As a side note, there's also a shortcut version :)

$(function() {});

If you can combine them, of course do so, if you need your code to be modular and you need multiple ready handlers, that's okay too, just make sure that the order is correct if it matters, usually it's a non-issue in those cases.

Nick Craver