setTimeout函数传递参数的“姿势”

  • setTimeout传参,我主要是做一个发送完验证码倒计时的功能,下面贴代码:
 var timeout = 60;
 function changeSendSmsButtonSecond(buttonId) {
            timeout--;
            if(timeout <= 0 ){
                timeout = 60;
                $(buttonId).text("获取验证码")
            }else{
                $(buttonId).text("重发(" + timeout + ")")
                setTimeout(changeSendSmsButtonSecond, 1000,buttonId)
            }

        }

        function changeSendSmsButton(buttonId) {
            $(buttonId).text("重发(" + timeout + ")")
            setTimeout(changeSendSmsButtonSecond, 1000,buttonId)
        }
  • 我用的语法是这样的 setTimeout(function, milliseconds, param1, param2, ...)

posted on 2020-07-02 10:38  愤怒的苹果ext  阅读(24)  评论(0编辑  收藏  举报

导航