<! DOCTYPE HTML > < HTML lang = "EN" > < head > < Meta charset = "UTF-. 8" > < title > Other 04-jQuery written entry function </ title > < Script the src = "JS / JQuery 1.12.4.js " > </ Script > < Script > // 1. The first writing $ (Document) .ready ( function () { // Alert (" Hello LNJ "); }); // 2. The second writing the jQuery (Document) .ready ( function () { // Alert ( "Hello LNJ"); }); // 3. The third writing (recommended) $ ( function () { // Alert ( "Hello LNJ"); }); // 4. The fourth writing the jQuery ( function () { alert("hello lnj"); }); </script> </head> <body> </body> </html>
Written above can be used in the project, personally recommend to use the third wording, simple and convenient