<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style type="text/css">
*{margin: 0;padding: 0;list-style:none;outline: none;border: 0;}
div{width: 100px;height: 50px;line-height: 50px;text-align: center;background: orange;color: #fff;margin: 100px;cursor: pointer;}
</style>
</head>
<body>
    <div id="rTime">点击发送</div>
<script type="text/javascript">if (typeof(rTime)=='undefined'&&!rTime) var rTime={};
rTime={
    _$ : function(d){
        return document.getElementById(''+d) || null;
    },

    sTime : function(g){
        if(typeof(g)=='number'&&g>0){
            this.g = g;
            this.t = g;
        }  
    },

    bind : function(b,d,e,fn){
        if(window.addEventListener){
            if(b){
                d.addEventListener(e,fn,false);
            }else{
                d.removeEventListener(e,fn,false);
            }
        }else{
            if(!b){
                d.attachEvent('on'+e,fn);
            }else{
                d.detachEvent('on'+e,fn);
            }
        }
    },

    dTime : function(t){
        var s = this, fn = function(){s.dTime('rTime');alert(1)};
        if(t!==undefined) var d = s._$(t);
        
        if(s.g!==undefined){
            if(s.g!==0){
                s.bind(false,d,'click',fn)
                d.innerHTML = s.g+'秒发送';
                window.setTimeout(function(){
                    s.g--;
                    s.innerHTML = s.g+'秒发送';
                    s.dTime('rTime');
                }, 200)
            }else{
                s.g=s.t;
                d.innerHTML = '重新发送';
                s.bind(true,d,'click',fn)
            }
        }
    }
}

rTime.sTime(1000);
rTime.dTime('rTime');

</script>
</body>
</html>