JQuery page Load initialization method There are 3 kinds of pages in the load when the script will be executed, there should be no difference, mainly look at the habit, I think the second method is the best, relatively concise.
The first type:
[JavaScript]View PlainCopy
- $ (document). Ready (function () {
- Alert ("the first method. ");
- });
The second type:
[JavaScript]View PlainCopy
- $ (function () {
- Alert ("the second method. ");
- });
The third type:
[JavaScript]View PlainCopy
- JQuery (function ($) {
- Alert ("the third method. ");
- });
PS; without jquery, in the method of page initialization,
1. Write OnLoad inside the body
2. Write in the script
[JavaScript]View PlainCopy
- window.onload=function () {
- //What to initialize
- }
Since jquery uses the $ notation to conflict with some components, such as DWR, in order to solve this problem, you can use the
[JavaScript]View PlainCopy
- var j = jquery.noconflict ();
This replaces the $ with "J".
(go, record with) 3 Ways to initialize jquery page loading