jQuery 入口函数主要有4种写法
jqery 入口函数主要有4种写法,其中以第3种方法最为方便。
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>Document</title> <script src=\'js/jquery-1.12.4.js\'></script> <script> //1. $(document).ready(function(){ alert(\'1111\'); }) //2. jQuery().ready(function(){ alert(\'222\'); }) //3. $(function(){ alert(\'gogo\'); }) jQuery(function(){ alert(\'hoho\'); }) </script> </head> <body> </body> </html>