微博2跟着老师的视频做出来了,if语句的功能没全部显示出来

Original 2019-02-06 16:58:23 212
abstract:<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=div, initial-scale=1.0"><meta h

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=div, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>仿微博输入框</title>

<style>

body{font-size:14px;}

.box1{width:753px;height:210px;border:1px solid #ffffff;border-radius:2px;padding:10px;margin:0px auto;background-color:#ffffff}

img{float:left;}

.box2{margin-left:500px;width:150px;height:30px;text-align:right;font-size:14px;color:#888;}

.box2 span{font-size:16px;font-weight:bold;}

#text{width:727px;height:100px;margin:10px auto;border:1px solid #375977}

.box1 #sp1,#sp2,#sp3,#sp4,#sp5,#sp6,#sp7{width:80px;height:40px;line-height:40px;padding-left:70px;}

.box1 #sp1{background:url(2.png) no-repeat  left center ;padding-left:34px}

.box1 #sp2{background:url(3.png) no-repeat  center;}

.box1 #sp3{background:url(4.png) no-repeat   center ;}

.box1 #sp4{background:url(5.png) no-repeat   center;}

.box1 #sp5{background:url(6.png) no-repeat   center;width:95; padding-left:85px ;}

/* 头条文章这,怎么也对不齐,要么图片之间间距不对,要么图片和文字间距不对 */

.box1 #sp6{width:30px;padding-left:20px;}

.box1 #sp7{width:30px;height:40px;margin-left:0px;padding-left:30px;}

.box1 #bt{width:80px;height:40px;margin-left:20px;background-color:#ff8000;border:none;border-radius:5px}

</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("字太多")

text.focus()

}else {

alert("发布成功")

}

}

}

</script>

</head>

<body>

<div class="box1">

<img src="1.png">

<div class="box2">还能输入<span id="number"></span>字</div>

<textarea id="text"></textarea>

<span id="sp1"> 表情</span>

<span id="sp2">图片</span>

<span id="sp3">视频</span>

<span id="sp4">话题</span>

<span id="sp5">头条文章</span>

<span id="sp6" style="font-weight:blod">.&nbsp .&nbsp .&nbsp </span>

<span id="sp7">公开</span>

<input type="button" id="bt" value="发布">

</body>

</html>


Correcting teacher:天蓬老师Correction time:2019-02-03 15:26:12
Teacher's summary:请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作业!!!请不要重复提交作

Release Notes

Popular Entries