简易的仿微博发布的效果

<!DOCTYPE html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>倒序插入li</title>
<style type="text/css">
#txt1{width:500px;
	height: 200px;
	resize:none;
	margin-left: 40px;}
#bnt1{
	margin-left: 50px;
	height: 35px;
	width: 50px;
	color: #ccc;
	background-color: green;}
#ul1 { list-style-type: decimal; }
#ul1 li{ border: 1px solid red; width: 50%;margin-top: 20px;}
</style>
</head>
<body>
	<textarea id="txt1" placeholder="请输入你要发表的内容" ></textarea>
    <input id="bnt1" type="button" value="发表" />
	<ul id="ul1">
	</ul>

	<script>
	window.onload=function()
	{
		var oBtn=document.getElementById("bnt1");
		var oU1=document.getElementById("ul1");
		var oTxt=document.getElementById("txt1");
		
		oBtn.onclick=function()
		{
			var oLi=document.createElement("li");
			var aLi=oU1.getElementsByTagName("li");
			oLi.innerHTML=oTxt.value;
			
			if(aLi.length>0)
			{
				oU1.insertBefore(oLi, aLi[0]);
			}
			else
			{
				oU1.appendChild(oLi);
			}
			
		}	
		
	}
</script>
</body>
</html>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值