找不到错误原因

<!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>

    <style>

        .text span {

            font-weight: bold;

            color: brown

        }


        em {

            font-style: normal

        }

    </style>

</head>


<body>

    <div>

        <p class="text">还可以输入

            <span>

                <em id="count">30</em>

            </span>

        </p>

        <div class="input">

            <textarea name="" id="" cols="70" rows="4"></textarea>


        </div>


    </div>

    <script>

        //获取文本框

        var text = document.getElementById("text");

        var abc = 30;

        var count = document.getElementById("count");

        //绑定键盘事件

        document.onkeyup = function () {

            //获取文本框长度

            var len = text.value.length;

            var changdu = abc -len;

            count.innerHTML = changdu

        }

    </script>


</body>


</html>


qq_胡思乱想_2
浏览 798回答 1
1回答

聪明的汤姆

给textarea加个id="text"<textarea name="" id="text" cols="70" rows="4"></textarea>把document换成texttext.oninput = function () {}望采纳~
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5
Java