JS 统计剩余次数

Original 2019-02-15 21:34:54 313
abstract:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">&

<!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>微博字数输入框</title>

<style type="text/css">

        body{font-size: 12px;}

        .box{width:600px;height: 160px;border: 10px solid pink;margin: 0px auto;padding:10px;}

        img{float: left;}

        .box1{float: left;margin-left: 250px;width: 150px;height:24px;text-align: right;font-size: 14px;color:#888;}

        .box1 span{font-size: 16px;font-weight: bold;}

        #text{width: 600px;height: 100px;border:1px solid #888;margin-top:5px;}

        .box #T1,#T2,#T3,#T4,#T5,#T6{float: left;width:30px;height: 32px;line-height: 32px;padding-left: 26px;}

        #T1{background: url(./pic/images/an5.png) no-repeat left center;}

        #T2{background: url(./pic/images/an4.png) no-repeat left center;}

        #T3{background: url(./pic/images/an3.png) no-repeat left center;}

        #T4{background: url(./pic/images/an2.png) no-repeat left center;}

        #T5{background: url(./pic/images/an1.png) no-repeat left center;width: 40px;}

        #T6{margin-left:145px;margin-right: 15px;color:#888; width: 40px;}

        #TT{width: 80px;height: 30px;border: none;color:#fff;float:left;border-radius: 5px;}

</style>

<script type="text/javascript">

        var text,number,m

        window.onload=function(){

            text=document.getElementById('text')

            number = document.getElementById('rest')

            text.onkeyup=function aa(){

                m=140-text.value.length;

                number.innerHTML=m;

            }

            aa()

        }

</script>

</head>

<body>

    <div class="box">

        <img src="./pic/images/12.png" alt="">

        <div class="box1">还可以输入<span id="rest" ></span>字</div>

        <textarea  id="text" ></textarea>

        <span id="T1">表情</span>

        <span id="T2">图片</span>

        <span id="T3">视频</span>

        <span id="T4">话题</span>

        <span id="T5">长微博</span>

        <span id="T6">公开</span>


        <input type="button" value="发布" id="TT" >

</div>

</body>

</html>


Correcting teacher:灭绝师太Correction time:2019-02-16 09:05:07
Teacher's summary:没有自己的思路,基本调试也没有,aa()这个函数可以去掉,调用aa()会报错

Release Notes

Popular Entries