The Document Ready Function
Share
The jQuery document ready function is used as an outer container for all of your jQuery functions and event code. It’s purpose is that it only loads the jQuery code once your HTML has fully loaded in the webpage. This allows it to add functions and events to HTML objects held within the DOM and prevent loading errors.
This is how you do it:
$(document).ready(function(){
// jQuery functions go here...
});