本帖最后由 aichenhongxin 于 2014-07-11 14:24:16 编辑

解决方案 »

  1.   

    你把show方法定义为一个局部方法了,外面访问不到。
      

  2.   

    卸载事件用off<!DOCTYPE html>
    <html>
    <head>
        <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.js"></script>
        <script type="text/javascript">
            $(function(){
                $('#aa').click(function(){
                    var nn=10;
                    function show(){
                        nn=nn-1;
                        if(nn!==0){
                            $('.cc').off().val(nn)                    }else{
                            clearInterval(set)
                            $('.cc').attr('id','aa')
                        }
                    }
                    var set=setInterval(show,1000);// 注意函数名没有引号和括弧!            })
            });
        </script>
    </head>
    <body>
    <input type="button" value="aa" id="aa" class="cc">
    </body>
    </html>