Js number of characters using the simple statistical input

<!DOCTYPE html>
<html>
<head>
    <title>137</title>
    <meta charset="utf-8">
    <script type="text/javascript">
        window.onload=function()
        {
            var a,b,w;
            a=document.getElementById("a");
            b=document.getElementById("b");


            a.onkeyup=function()
            {
                            w=a.value;
            var s=w.length;
            b.innerHTML=s;
        }
    }
    </script>
</head>
<body>
    <input type="text" id="a" size="20">
    字符的个数是 <span id="b">0</span>
</body>
</html>

Guess you like

Origin blog.csdn.net/qq_39485970/article/details/82901530