Binds a function to execute when DOM loading is ready to be queried and manipulated.
This is the most important function in the event module, because it can greatly improve the responsiveness of the Web application.
Simply put, this method is purely an alternative to registering events with the Window.load event. By using this method, you can immediately invoke the function you are bound to when the DOM loading is ready to be read and manipulated, and 99.99% of the JavaScript functions need to be executed at that moment.
There is a parameter--a reference to the jquery function--is passed to the ready event handler. You can give this parameter any name, and you can safely use the $ alias without worrying about naming conflicts.
Make sure that no function is registered in the OnLoad event of the <body> element, otherwise the +$ (document). Ready () event is not triggered.
You can use the $ (document). Ready () event indefinitely on the same page. The functions that are registered are executed sequentially in order (in the code).
Describe:
The code that runs when the DOM load is complete can be written like this:
JQuery Code:
$(document).ready(function(){ // 在这里写你的代码...});
Describe:
Use $ (document) for shorthand, while the internal JQuery code still uses $ as an alias, regardless of the global $.
JQuery Code:
$(function($) { // 你可以在这里继续使用$作为别名...});
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
$ (function () {}) in jquery;