seems unbelieveable.
JS 闭包 计数器
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
# <html>
# <head>
# <title>JS Counter</title>
# <script type="text/javascript">
# var Counter=(function(){
#
# //赋初值
# var count=0;
#
# //外部调用时形成闭包
# return function(){
# return ++count;
# }
# })()
#
# window.onload=function(){
# document.getElementById('btn').onclick=function(){
# alert(Counter());
# }
# }
#
# </script>
#
# </head>
#
# <body>
# <input type='button' id='btn' value='Counter' />
# </body>
# </html>
JS 闭包 计数器
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
# <html>
# <head>
# <title>JS Counter</title>
# <script type="text/javascript">
# var Counter=(function(){
#
# //赋初值
# var count=0;
#
# //外部调用时形成闭包
# return function(){
# return ++count;
# }
# })()
#
# window.onload=function(){
# document.getElementById('btn').onclick=function(){
# alert(Counter());
# }
# }
#
# </script>
#
# </head>
#
# <body>
# <input type='button' id='btn' value='Counter' />
# </body>
# </html>
解决方案 »
- 严重: Servlet.service() for servlet [jsp] in context with path [/mybbs] threw exce
- 如何用JAVASCRIPT添加标签?
- 散分300,脚本应用小制作--CSDN发图工具,以下代码另存为*.hta,双击运行即可。
- 如何得到一个只要内部线,不要外部线的表格
- 有个个表单名一样的表单元素,如何知道它是第几个表单?
- 如何加入限制,只能输入文字或数字,请大家帮下忙~~
- 新人需要前辈门指点
- 大家好,请教如何使用WdatePicker.js的来封装日期?
- 郁闷哦~~~~关于框架访问的问题。。。
- 哪儿有javascript语法参考手册!!!!
- 求助colorbox问题
- jquery没有自动提示
var test = function(){
var a="helloworld";
return function(){return a}; //a is js closure}