返回 微博输入文字案...... 登陆

微博输入文字案例

A.duang 2019-01-01 07:18:26 263
<!DOCTYPE html>
<html>
<head>
	<title>腾讯微博</title>
	<link href="http://netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
	<style type="text/css">
		body {
			background-color: #ccc;
			font-size: 14px;
			color: #999;
		}
		.box {
			width: 600px;
			height: 200px;
			background-color: #fff;
			margin: 0 auto;
			border-radius: 5px;
			padding: 20px;
		}
		p {
			float: left;
			margin: 0;
		}
		.box1 {
			float: left;
			margin-left: 220px;
			width: 150px;
			height: 24px;
			text-align: right;
		}
		.box1 span {
			font-size: 16px;
			font-weight: bold;
		}
		#txt {
			width: 600px;
			height: 100px;
			margin-top: 5px;
			border-radius: 5px;
		}
		.box #sp1,#sp2,#sp3,#sp4,#sp5 {
			float: left;
			width: 30px;
			height: 32px;
			line-height: 32px;
			padding-left: 20px;
			margin-right: 10px;
		}
		#sp1 {
			background: url(images/a3.png) no-repeat left center;
		}
		#sp2{
			background: url(images/a2.png) no-repeat left center;
		}
		#sp3 {
			background: url(images/a1.png) no-repeat left center;
			margin-right: 10px;
		}
		#sp4 {
			padding-left: 5px;
		}
		#sp5 {
			background: url(images/a4.png) no-repeat left center;
			margin-left: 260px;
			width: 85px;
		}
	</style>
	<script type="text/javascript">
		var txt,number,m,sp5
		window.onload = function(){
			txt = document.getElementById('txt');
			alert (txt.value.length);
			number = document.getElementById('number');
			sp5 = document.getElementById('sp5');
			txt.onkeyup = function aa(){
				m = 140-txt.value.length;
				if(m<0) {
					number.style.color = 'red';
				} else {
					number.style.color = '#888';
				}
				number.innerHTML = m;
			}
			sp5.onclick = function (){
				if(m == 140){
					alert ('请输入内容');
					txt.focus();
				}
				else if(m < 0){
					alert('输入过多');
					txt.focus();
				} else {
					alert('发布成功');
				}

			}
			aa();
		}
	</script>
</head>
<body>
<div class="box">
	<p>来,说说你在做什么,想什么</p>
	<div class="box1"">还能输入<span id="number"></span>字</div>
	<textarea id="txt"></textarea>
	<span id="sp1">表情</span>
	<span id="sp2">图片</span>
	<span id="sp3">朋友</span>
	<span id="sp4">更多<i class="fa fa-caret-down" style="float: left; margin-top: -22px; margin-left: 32px;"></i></span>
	<span id="sp5"></span>
</div>
</body>
</html>

a1.pnga2.pnga3.pnga4.png



老师。这个里面带有图片了,又不能上传文件夹,所以我选择了这种方法。。然后这个js判断m==140是不生效的,请老师指教。最后请老师不要通过,这个作品是不完美的

最新手记推荐

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

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网