1. 程式人生 > 其它 >自定義異常和小結

自定義異常和小結

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <button>獲取驗證碼</button>
    <script>
        var
t var btn = document.querySelector('button') console.log(btn) btn.onclick = function () { btn.disabled = true btn.innerHTML = '10s倒計時' clearInterval(t) var count = 10 t = setInterval(function () { count
-- btn.innerHTML = count + 's' if (count <= 0) { clearInterval(t) btn.disabled = false btn.innerHTML = '10s倒計時' } }, 1000) } </script> </body> </html>