The HTML Document Object Model (DOM) is the interface in which one can add, delete, or edit objects in an HTML file. When you open an HTML file, the DOM must be loaded to ensure the file is working correctly.
Once your DOM is loaded, i.e. the entire tree of data has been created then you can start adding external elements into the HTML file.
The ready
method allows you to wait for the DOM to be loaded before you add other elements to your HTML file.
ready
methodThe ready
method is called on the document
in the following way:
$(document).ready(function);
Note: Post jQuery 3.0, this way of calling the ready function is not advisable. Rather you simply call the function as
$(function)
as the ready method is only called on the current document.
Ready
method valueUsing this method allows time for your DOM to be loaded completely, and then it adds all other elements.
Also, this is a space where you can fire all other events that you need. Within the ready
method you can call any events which will be executed in chronological order.
Free Resources