abstract:<!DOCTYPE html> <html> <head> <title>微博输入字数(2)</title> <meta charset="utf-8"> <style type="text/css"> .box{width: 
<!DOCTYPE html> <html> <head> <title>微博输入字数(2)</title> <meta charset="utf-8"> <style type="text/css"> .box{width: 600px;height: 200px;border: 10px solid pink;padding: 10px;} .img1{float: left;} .box1{float: right;margin-right: 10px;font-size: 14px;color: #888;height: 30px;} #text1{width: 590px;height: 120px;border: 1px solid #ccc;} .box #span1,#span2,#span3,#span4,#span5,#span6{ width: 35px;height: 40px;line-height: 40px;float: left;padding-left: 25px;font-size: 12px; } #span1{background: url(images/an5.png) no-repeat left center;} #span2{background: url(images/an4.png) no-repeat left center;} #span3{background: url(images/an3.png) no-repeat left center;} #span4{background: url(images/an2.png) no-repeat left center;} #span5{background: url(images/an1.png) no-repeat left center;width: 50px;} #span6{margin-left: 120px;margin-right: 10px;} #button1{width: 90px;height: 35px;background-color: pink;float: left;border: none;color: #fff;} </style> </head> <body> <script type="text/javascript"> window.onload=function () { var nu,m,text,bt; nu=document.getElementById('number') bt=document.getElementById('button1') text=document.getElementById('text1') text.onkeyup=function aa() { m=140-text.value.length if (m<0) { nu.style.color="red" }else{ nu.style.color="#888" } nu.innerHTML=m } bt.onclick=function bb() { if (m==140) { alert("请输入内容"); text.focus() }else if (m<0) { alert("字数超出限制") text.focus() }else{ alert("发布成功") } } } </script> <div class="box"> <img src="images/12.png" class="img1"> <div class="box1">还可以输入<span id="number"></span>字</div> <textarea id="text1"></textarea> <span id="span1">表情</span> <span id="span2">图片</span> <span id="span3">视频</span> <span id="span4">话题</span> <span id="span5">长微博</span> <span id="span6">公开</span> <input type="button" name="" id="button1" value="发布"> </div> </body> </html>
Correcting teacher:灭绝师太Correction time:2019-01-15 09:11:55
Teacher's summary:完成的不错,aa()这个函数名可以去掉,老师这里创建的aa()是没必要的……