abstract:工作涉及到前后端,但之前基本是自学,知识不系统,基础不牢固,之前总是要想半天,单选怎么传值,复选怎么传值,文本域怎么传值等等,学完JS这一阶段的课之后,发现其实都很简单,基础掌握牢固了,举一反三灵活运用就可以,JS的一些常用内置函数是死的,需要灵活运用,或者根据自己的需要自定义函数,再来调用,后面希望能有更深入的学习<!doctype html><html> &l
工作涉及到前后端,但之前基本是自学,知识不系统,基础不牢固,之前总是要想半天,单选怎么传值,复选怎么传值,文本域怎么传值等等,学完JS这一阶段的课之后,发现其实都很简单,基础掌握牢固了,举一反三灵活运用就可以,JS的一些常用内置函数是死的,需要灵活运用,或者根据自己的需要自定义函数,再来调用,后面希望能有更深入的学习
<!doctype html>
<html>
<head>
<meta charset="gbk">
<title>微博输入1作业</title>
</head>
<style>
body{font-size:12px}
.box{border:8px solid pink;margin:0 auto;width:600px;height:160px;padding:10px}
.box1{float:left;margin-left:300px;font-size:14px;color:#888}
img{float:left}
#text{width:600px;height:100px}
.box #sp1,#sp2,#sp3,#sp4,#sp5,#sp6{float: left;width: 30px;height: 32px;line-height: 32px;padding-left: 26px;}
#sp1{background: url(images/an5.png) no-repeat left center;}
#sp2{background: url(images/an4.png) no-repeat left center;}
#sp3{background: url(images/an3.png) no-repeat left center;}
#sp4{background: url(images/an2.png) no-repeat left center;}
#sp5{background: url(images/an1.png) no-repeat left center;width: 40px;}
#sp6{margin-left: 158px;margin-right:15px;color: #888; }
#bt{float: left;width: 80px;height: 30px;border: none;background: #ffc09f;color: #fff;border-radius: 5px;}
</style>
<script>
var text,number, m
window.onload=function(){
text = document.getElementById('text');
number = document.getElementById('number')
btn = document.getElementById('bt');
text.onkeyup = function sum(){
m = 140-text.value.length;
if(m<0){
number.style.color='red'
}else{
number.style.color='#888'
}
number.innerHTML=m;
}
btn.onclick = function(){
if(m==140){
alert('您还未输入,请输入')
}else if(m<0){
alert('字数过多,发布失败')
}else{
alert('发布成功')
}
sum();
}
}
</script>
<body>
<div>
<img src="images/12.png" alt="">
<div>还可以输入<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'>公开</span>
<input type="button" value="发布" id="bt">
</div>
</body>
</html>
Correcting teacher:韦小宝Correction time:2018-12-25 09:37:13
Teacher's summary:现在发现之前感觉复杂的半天解决不了的都很简单了吧!这都是正常的!说明是真的认真了!