摘要:<!doctype html><html><head><meta charset="UTF-8"><title>微博輸入</title><style>body{font-size: 12px;}.box{width: 550px;height: 160px;border:7px solid pi
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>微博輸入</title>
<style>
body{font-size: 12px;}
.box{width: 550px;height: 160px;border:7px solid pink;margin: 20px auto;padding: 15px;}
img{float: left;width: 130px;height: 20px;margin-left: 20px;margin-top: 5px;}
.box1{float: left;width: 150px;height: 20px;font-size: 12px;line-height: 20px;margin-top: 8px;margin-left: 230px;}
#number{font-size: 14px;font-weight: bold;}
#text{width: 550px;height: 100px;padding: 5px;}
.box #sp1,#sp2,#sp3,#sp4,#sp5,#sp6{float: left;height:
24px;line-height: 24px;padding: 2px 17px;margin-right: 0px;}
#sp1{background: url(images/time.png) no-repeat left center;}
#sp2{background: url(images/tag.png) no-repeat left center;}
#sp3{background: url(images/user.png) no-repeat left center;}
#sp4{background: url(images/stopplay.png) no-repeat left center;}
#sp5{background: url(images/toend.png) no-repeat left center;}
#sp6{margin-left: 125px;margin-right: 2px;color: #888;}
#anniu{color: #fff;border: none; border-radius: 5px;background: pink;width: 80;height: 26px;}
</style>
<script>
var text,number,m;
window.onload=function(){
text=document.getElementById("text");
number=document.getElementById('number');
anniu=document.getElementById("anniu");
text.onkeyup=function(){
m=140-text.value.length;
if (m<0) {
number.style.color="red";
}else{
number.style.color="#888";
}
number.innerHTML=m;
}
anniu.onclick=function(){
if (m==140) {
alert("你還沒有輸入。");
text.focus();
}else if(m<0 ){
alert("字?jǐn)?shù)過得,不能發(fā)布。");
text.focus();
}else{
alert("發(fā)布成功。");
}
}
}
</script>
</head>
<body>
<div>
<img src="images/weibo1.png" alt="">
<div>你還可以輸入<span id="number"></span>個字</div>
<textarea name="" id="text" rows="10"></textarea>
<span id="sp1">表情</span>
<span id="sp2">圖片</span>
<span id="sp3">視頻</span>
<span id="sp4">話題</span>
<span id="sp5">長微博</span>
<span id="sp6">公開</span>
<input type="button" value="發(fā)布" id="anniu">
</div>
</body>
</html>
批改老師:韋小寶批改時間:2019-03-09 15:15:03
老師總結(jié):寫的還算是很不錯的 等有時間可以通過jQuery來改寫一下哦 還可以把jQuery練習(xí)練習(xí)