????:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>微博作業(yè)</title> <style> *{margin: 0;padding: 0} .clear{clear: both
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>微博作業(yè)</title> <style> *{margin: 0;padding: 0} .clear{clear: both;} a{text-decoration: none;color: black;font-size: 15px;} .box{width: 700px;height: 168px;margin: 10px auto;border: 1px solid red;} .top{width: 700px;height: 35px;line-height: 35px;position: relative;} .top_left{float: left;margin-left: 8px;} .top_left img{width: 245px;height: 30px;position: absolute;top: 5px;} .top_right{float: right;margin-right: 8px;} .content{width: 700px;height: 75px;} .content textarea{width: 680px;height: 75px;margin: 0 auto;display: block;border: 1px solid black;} .down{width: 700px;height: 52px; line-height: 52px;} .down_left{float: left;margin-right: 8px;} .down_left span{padding-left: 23px;} .down_right{float: right;margin-left: 18px;} .down_right input{width: 88px;height: 32px;border: none;background: orange;margin-right: 8px;border-radius: 5px;font-size: 15px;} #d1{background: url(image/2.png)no-repeat left center;} #d2{background: url(image/3.png)no-repeat left center;} #d3{background: url(image/4.png)no-repeat left center;} #d4{background: url(image/5.png)no-repeat left center;} #d5{background: url(image/6.png)no-repeat left center;} #d6{background: url(image/7.png)no-repeat left center;} </style> <script type="text/javascript"> var text,number,m window.onload=function(){ text=document.getElementById('text') number=document.getElementById('number') bt=document.getElementById('bt') text.onkeyup=function aa(){ m=140-text.value.length if(m<0) { number.style.color="red" }else{ number.style.color="#888" } number.innerHTML=m } bt.onclick=function(){ if(m==140) { alert("你還沒有輸入") text.focus() }else if (m<0) { alert("字?jǐn)?shù)太多,不可以發(fā)布") text.focus() }else{ alert("發(fā)布成功") } } aa() } </script> </head> <body> <div> <div> <div> <img src="image/1.png" alt="有什么新鮮事想告訴大家?"> </div> <div> <div>還可以輸入<span id="number"></span>字</div> </div> </div><div></div> <div> <textarea id="text" ></textarea> </div> <div> <div> <span id="d1"><a href="#">表情</a></span> <span id="d2"><a href="#">圖片</a></span> <span id="d3"><a href="#">視頻</a></span> <span id="d4"><a href="#">話題</a></span> <span id="d5"><a href="#">頭條文章</a></span> <span id="d6"><a href="#">···</a></span> </div> <div> <span id="d7"><a href="#">公開</a></span> <input type="button" value="發(fā)布" id="bt"> </div> </div> </div> </body> </html>
?? ???:滅絕師太?? ??:2019-02-14 15:29:29
???? ??:老師的源碼中有個(gè)bug,aa()這個(gè)函數(shù)可以去掉,雖然有效果也可以實(shí)現(xiàn),但是你沒有發(fā)現(xiàn)有個(gè)報(bào)錯(cuò)么,找找原因