摘要:<!DOCTYPE html> <html dir="ltr"> <head> <meta charset="utf-8"> <title>微博<
<!DOCTYPE html>
<html dir="ltr">
<head>
<meta charset="utf-8">
<title>微博</title>
<style media="screen">
.b1{width:600px;height:160px;border:10px solid pink;margin:0px auto;padding:10px;}
img{float:left;}
#text{width:600px;height:100px;border:1px solid #888;margin-top:5px;}
.b2{float:right;font-size:14px;color:#888;margin-right:5px;}
span{font-size:13px;}
#s1,#s2,#s3,#s4,#s5,#s6{float: left;width: 30px;height: 32px;line-height: 32px;padding-left: 26px;}
#s1{background: url(images/an5.png) no-repeat left center;}
#s2{background: url(images/an4.png) no-repeat left center;}
#s3{background: url(images/an3.png) no-repeat left center;}
#s4{background: url(images/an2.png) no-repeat left center;}
#s5{background: url(images/an1.png) no-repeat left center;width: 40px;}
#s6{ margin-left: 158px;margin-right:15px;color: #888; }
#fb{width: 80px;height: 30px;border: none;background: #ffc09f;color: #fff;border-radius: 5px;}
#num{font-size:16px;font-weight:bold;}
</style>
</head>
<body>
<div>
<img src="./images/12.png" alt="">
<div>
还可以输入<span id="num"></span>字
</div>
<textarea id="text"></textarea>
<span id="s1">表情</span>
<span id="s2">图片</span>
<span id="s3">视频</span>
<span id="s4">话题</span>
<span id="s5">长微博</span>
<span id="s6">公开</span>
<input type="button" id="fb" onclick="cc()" value="发布">
</div>
</body>
<script type="text/javascript">
var text,num,m;
window.onload=function(){
text=document.getElementById('text');
num=document.getElementById('num');
text.onkeyup=function aa(){
m=140-text.value.length;
if(m<0){
num.style.color="red";
}else{
num.style.color="#888";
}
num.innerHTML=m;
}
}
function cc(){
if(m==140){
alert("你还没有输入");
}else if(m<0){
alert("字数太多,发布失败");
}else{
alert("发布成功");
}
}
</script>
</html>
批改老师:韦小宝批改时间:2019-03-14 09:15:24
老师总结:这一篇也是和上一篇差不多 外在复习了js部分的知识了 没事就是要这样去多练习练习