返回微博输入数字...登陆

微博输入数字

移动用户-97317832019-03-24 19:57:15289

<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <title>为什么“表情”“图片”前面插入的图片使用的是“background-image”,而不是用img</title>
   <style>
     body{font-size:12px;}
     .box{
       width:600px;
       height:160px;
       border:10px solid pink;
       margin:20px auto;
       padding:10px;
     }
     .box1{
       float:right;
       margin-right:4px;
       font-size:14px;
       color: #888;
     }
     #number{
       font-size:16px;
       font-weight:bold;
     }
     #text{
       width:600px;
       height:100px;
       display:block;
     }
     #sp1,#sp2,#sp3,#sp4,#sp5,#sp6{
       width:30px;
       height:32px;
       line-height:32px;
       padding-left:22px;
       margin-right:8px;
     }
     #sp1{background:url(static/images/an5.png) no-repeat left 45%;background-size:46%;}
     #sp2{background:url(static/images/an4.png) no-repeat left 45%;background-size:46%;}
     #sp3{background:url(static/images/an3.png) no-repeat left 45%;background-size:46%;}
     #sp4{background:url(static/images/an2.png) no-repeat left 45%;background-size:46%;}
     #sp5{background:url(static/images/an1.png) no-repeat left 45%;background-size:46%;}

     #sp6{margin-left:160px;color:#888;}

     #bt{width:80px;height:30px;border:none;outline:none;color:#fff;background:orange;position:relative;right:-9px;top:2px;}
   </style>
</head>
<body>
<div class="box">
 <img src="static/images/12.png">
 <div class="box1">还可以输入<span id="number">140</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>
<script>
 function getObj(idName){
   return document.getElementById(idName);
 }
 var text,number,bt,m,len;
 text = getObj('text');
 number = getObj('number');
 bt = getObj('bt');


 text.onkeydown = function(){
   if(text.value.length == undefined){
     len = 0;
   }else{
     len = text.value.length;
   }
   m = 140 - len;
   number.innerHTML = m;
   if(m<0){
     number.style.color = 'red';
   }else{
     number.style.color = '#888';
   }
 }
 bt.onclick = function(){
   if(text.value.length == undefined){
     len = 0;
   }else{
     len = text.value.length;
   }
   m = 140 - len;
   number.innerHTML = m;
   if(m == 140){
     alert("输入框不能为空");
     text.focus();
   }else if(m < 0){
     alert("输入的字符不能超过140个");
     text.focus();
   }else{
     alert("发表成功");
   }
 }
</script>
</body>
</html>

最新手记推荐

• 用composer安装thinkphp框架的步骤• 省市区接口说明• 用thinkphp,后台新增栏目• 管理员添加编辑删除• 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消回复发送