<SCRIPT src = "scripts/jquery-1.3.1.js"> </SCRIPT> <SCRIPT type = "text/JavaScript"> // $ (document ). ready (function () {// alert ("Hello, world! "); //}); Window. onload = function () {alert (" Hello, world! ") ;}</SCRIPT>
Window. onload:
You must wait until all content on the webpage is loaded;
You cannot concatenate multiple functions at the same time.Code:
Window. onload = function (){
Alert ("Hello, world 0! ");
};
Window. onload = function (){
Alert ("Hello, world 1! ");
}
Only execute alert ("Hello, world 1! ");
$ (Document). Ready ():
After the DOM structure is drawn, it is executed;
You can write multiple,
$ (Document). Ready (function (){
Alert ("Hello, world! ");
});
$ (Document). Ready (function (){
Alert ("Hello, world! 3 ");
});
Execute alert ("Hello, world! "); Then execute alert (" Hello, world! 3 ");
Can be abbreviated:
$ (Funtion (){
}