<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>提交输入框内容到文本域 公告窗</title>
<style>
div#content{
border:1px solid blue;
text-align:left;
overflow:auto;
height:200px;
width:400px;
}
</style>
<script>
var show = function(){
//重新显示的文本为追加(+=)内容
content.innerHTML += inputContent.value + "<br />";
content.scrollTop = content.scrollHeight;
inputContent.value = "";
}
</script>
</head>
<body>
<center>
公告墙 <br><br>
<div id='content'>
今天我觉得天气不错<br>你觉得天气怎么样呢<br>
</div> <br />
<input type="text" id="inputContent" placeholder="请输入内容" /> <br />
<button οnclick="show()"> 发布 </button>
</center>
</body>
</html>
<html>
<head>
<meta charset="UTF-8">
<title>提交输入框内容到文本域 公告窗</title>
<style>
div#content{
border:1px solid blue;
text-align:left;
overflow:auto;
height:200px;
width:400px;
}
</style>
<script>
var show = function(){
//重新显示的文本为追加(+=)内容
content.innerHTML += inputContent.value + "<br />";
content.scrollTop = content.scrollHeight;
inputContent.value = "";
}
</script>
</head>
<body>
<center>
公告墙 <br><br>
<div id='content'>
今天我觉得天气不错<br>你觉得天气怎么样呢<br>
</div> <br />
<input type="text" id="inputContent" placeholder="请输入内容" /> <br />
<button οnclick="show()"> 发布 </button>
</center>
</body>
</html>