abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>weibo</title><style type="text/css">body{font-size:12px;}.clear{clear:both;}.left{
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>weibo</title>
<style type="text/css">
body{font-size:12px;}
.clear{clear:both;}
.left{float: left; margin-left: 15px; margin-top:5px;font-size:14px;}
</style>
<script type="text/javascript">
var text,number,margin
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("你输入的字符超过140字啦!请减少字数!")
text.focus()
}else{
alert("发布成功啦!")
}
}
}
</script>
</head>
<body>
<div style="width: 580px; margin: 0 auto;">
<div style="float: left;font-size:16px;">有什么新鲜事想告诉大家?</div>
<div style="float: right;color:grey;">已输入<span id="number">140</span>字</div>
<div></div>
<textarea id="text" style="width: 580px; height: 80px;font-size: 16px;" onkeyup="aa()"></textarea>
<span>※ 表情</span>
<span>※ 图片</span>
<span>※ 视频</span>
<span>※ 话题</span>
<span>※ 头条文章</span>
<input type="submit" id="bt" style="float:right;font-size:14px;color:#fff;background-color: #ff7f4d;padding:5px 20px;">
<div></div>
</div>
</body>
</html>
Correcting teacher:灭绝师太Correction time:2019-01-30 09:28:23
Teacher's summary:完成的不错 , 可以试试其他方法完成字数控制