返回在线聊天功能的......登陆

在线聊天功能的实现

方山2019-03-08 17:05:59300

<!DOCTYPE html>


<html>

<head>


<meta charset="UTF-8">


<meta name="viewport" content="width=device-width, initial-scale=1.0">


<meta http-equiv="X-UA-Compatible" content="ie=edge">


<title>Chat_Room_Case</title>


<style>

* {


padding: 0;


margin: 0;


}




ul li {


list-style: none;


margin-left: -200px;


padding: 4px;


}


.container {


margin: 0 auto;


text-align: center;


margin: 15px;


}



.container .chatbox {


margin: 0 auto;


width: 300px;


height: 400px;


border: 1px solid #ccc;


}




.container .chatbox span {


display: block;


width: 100%;


color: #fff;


background: #5c28d4;


}




.container .btn {


margin: 0 auto;


width: 120px;


height: 45px;


color: #fff;


letter-spacing: 12px;


background: rgb(26, 121, 199);


border-radius: 5px;


text-align: center;




}




.container .msg {


height: 40px;


border: 1px solid #ddd;


padding: 0 5px;




}

</style>


</head>




<body>


<div class="container">


<div id="cbox" class="chatbox">


<span style="font-size:20px;">Welcome to this Chatroom</span>


<hr>


<ul>


<li></li>


</ul>


</div>


<div>


<input type="text" placeholder="欢迎来到本聊天室......."class="msg"> <button class="btn">发送</button></div>


</div>


<script>


let input = document.getElementsByClassName('msg')[0];


let ul = document.getElementsByTagName('ul')[0];


let button = document.getElementsByClassName('btn')[0];


button.onclick = function () {


let li = document.createElement('li');


li.innerHTML = input.value;


ul.appendChild(li);


input.value = '';


}


</script>


</body>


</html>


最新手记推荐

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

全部回复(0)我要回复

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