提交输入框内容到文本域 公告窗

来源:互联网 发布:mysql教学视频 百度云 编辑:程序博客网 时间:2024/06/06 10:46
<!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 onclick="show()"> 发布  </button> 
</center>
</body>
</html>
阅读全文
0 0
原创粉丝点击