<script src="~/js/jquery.min.js"></script> <script> window.onload = function () { $("#Button1").click(function () { //function foo(x) { // var tmp = 3; // function bar(y) { // alert(x + y + (++tmp)) // } // bar(10); //} //foo(2); function foo(x) { var tmp = 3; return function (y) { alert(x + y + (++tmp)) } } var bar = foo(2);// bar 现在就是一个闭包 bar(10); }) } </script>