jQuery ready event:-
JQuery’s document.ready() method allows you to run code as soon as the document is ready to be manipulated.
For example, if a browser supports the DOMContentLoaded event (as many non-IE browsers do), then it will fire on that event. However, IE8 doesn't have a domcontentloaded event, that came out in IE9.
Syntax used for jQuery ready:
//write you code
The ready() method can only be used on the current document, so no selector is required:
There are following points for document.ready():-
- It will not wait any images to get loaded.
- It can be used multiple times.
- Not used if you want to manipulate images Use $(window).load() instead.
- Replace $ with jQuery when you receive “$ is not defined.”