Reputation: 23290
I'm newbie to jQuery (I came to JavaScript from PHP).
I grouped multiple jQ functions in seperate files. I have the following questions:
$(document).ready(function () { });
. Can I use Domready more than 1 time?Upvotes: 2
Views: 240
Reputation: 60316
Fairly simple answers to your questions:
Upvotes: 1
Reputation: 673
Not really. Although I do not have enough information comment fully I can say that you only want to execute jquery on "ready" to run jquery on page load. Typically you will want to build jquery based functions and call these at the appropriate times. You can how ever call jquery in different ways, ie: Most importantly I think is that you usually want to make sure the whole DOM structure is loaded.
jQuery.("#id").doStuff(); $("#id).doStuff();
Upvotes: 1
Reputation: 16945
No, you do not have to have every jquery function within the document ready handler. But if your code references any part of the DOM, you should have it within that context.
You can have any number of functions bound to any event, including document.ready. So feel free to use $(document).ready(function () { }); or even better $(function () {}) all you want.
Upvotes: 2