This article mainly introduces the automatic loading of javaScript pages. If you need it, you can refer to it for help.
Method 1:
The Code is as follows:
Window. onload = function (){
Var name = document. getElementById ("name"). val (); // load HTML and all external reference files (images, css styles, js, etc)
}
Method 2: Introduce Jquery's. js File
The Code is as follows:
$ (Document). ready (function (){
Alert ("JQuery's first entry case"); // load HTML, no need to wait, load now
});
Method 3: (equivalent to method 2)
The Code is as follows:
JQuery (function (){
If ($ ("input [name = 'message']"). val ()! = "")
Alert ($ ("input [name = 'message']"). attr ("value "));
});
Method 4: (equivalent to above)
The Code is as follows:
$ (Function (){
Alert ("when the JQuery page is automatically loaded, execute 1 ....");
});
Method 5-1: loading window. onload event (multiple functions are loaded simultaneously when the page is loaded ...)
The Code is as follows: