摘要:<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>微博输入</title>  
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>微博输入</title>
<style type="text/css">
#box1{width: 600px;height: 190px;border: 10px solid pink;margin:0 auto;}
#box2{width: 600px;height: 35px;color: #888897;font-size: 14px;}
#box2 span{margin-left: 270px;}
#box2 img{width: 190px;height: 24px;margin-top: 6px;}
#box3 textarea{width: 550px;height: 100px;padding:10px;margin-left: 13px;}
#box4{font-size: 12px;}
#box4 span{width: 50px;height: 20px;display: inline-block;text-align: right;line-height: 20px;}
#box4 #span1{background: url(images/an5.png) no-repeat ;}
#box4 #span2{background: url(images/an4.png) no-repeat ;}
#box4 #span3{background: url(images/an3.png) no-repeat ;}
#box4 #span4{background: url(images/an2.png) no-repeat ;}
#box4 #span5{background: url(images/an1.png) no-repeat ;width: 60px;}
#box4 #span6{margin-left: 150px;}
#box4 #bt{margin-left: 20px;width: 80px;height: 25px;border: none;background-color: #FFC09F;color: #fff;border-radius: 5px;}
</style>
<script type="text/javascript">
window.onload=function(){
var number,m,text;
number = document.getElementById('number');
text=document.getElementById('text');
text.onkeyup=function b(){
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("字数太多,不可以发布");
text.focus();
}else{
alert("发布成功");
}
}
}
</script>
</head>
<body>
<div id="box1">
<div id="box2">
<img src="images/12.png">
<span>还可以输入</span><i id="number"></i>字
</div>
<div id="box3">
<textarea id="text"></textarea>
</div>
<div id="box4">
<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 id="bt" type="submit" value="发布"">
</div>
</div>
</body>
</html>老师写的代码中,js中函数aa已经绑定了键盘被松开的事件,可以直接触发函数,但是老师在后面又调用了一次函数aa,结果浏览器出现报错aa未定义,后来我删掉这个aa函数的调用,就没有报错了
批改老师:韦小宝批改时间:2019-03-10 13:12:18
老师总结:写的很不错 老师在写的时候难免会出现一些小问题 自己发现要注意自己以后不能犯哦