用js显示验证码

 

        function getCode() {
            let code = [];
            let num = parseInt(Math.random() * 10);
            let num1 = parseInt(Math.random() * 10);
            let zm_x1 = String.fromCharCode(parseInt(97 + Math.random() * 26));
            let zm_x = String.fromCharCode(parseInt(97 + Math.random() * 26));
            let zm_d = String.fromCharCode(parseInt(65 + Math.random() * 26));
            code.push(num, zm_x, zm_d, zm_x1, num1);
            return `${code[parseInt(Math.random() * 5)]}${code[parseInt(Math.random() * 5)]}${code[parseInt(Math.random() * 5)]}${code[parseInt(Math.random() * 5)]}`
        }
        let time = document.getElementById('time');
        setInterval(function () {
            time.innerText = getCode();
        }, 1000)

 

posted @ 2019-02-25 22:41  平平无奇小辣鸡  阅读(243)  评论(0)    收藏  举报