(function($){...})(jQuery)
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <script type="text/javascript" src="jquery-1.9.0.min.js"></script> <title>Insert title here</title> <script type="text/javascript"> $(function(){ //匿名函数,形参$ ,实参"bb" (function($){alert($);})("bb"); //等价于 var c = function(param){alert(param);} c("aa"); //这样写的好处,避免变量污染,让匿名函数立即执行 alert($); }); </script> </head> <body> <input type="button" disabled="disabled" id="aaa" /> </body> </html>