亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

再次完善在線(xiàn)客服聊天系統(tǒng)

original 2019-03-09 12:03:17 334
abstrait:<!-- 本次作業(yè)再次完善了在線(xiàn)客服聊天系統(tǒng)。主要增加了,1、禁止發(fā)送空消息功能(直接通過(guò)if語(yǔ)句判斷Input.value是否為空);2、在消息內(nèi)容前面增加了頭像;3、通過(guò)一個(gè)字符串?dāng)?shù)組預(yù)置一些聊天語(yǔ)句,利用settimeout()函數(shù)定時(shí)通過(guò)Math.fllor(Math.random())方法進(jìn)行隨機(jī)讀取聊天語(yǔ)句,拼接上頭像文件在指定的ul li中顯示。同時(shí)記錄li的數(shù)量,在達(dá)到10條

<!-- 本次作業(yè)再次完善了在線(xiàn)客服聊天系統(tǒng)。主要增加了,1、禁止發(fā)送空消息功能(直接通過(guò)if語(yǔ)句判斷Input.value是否為空);2、在消息內(nèi)容前面增加了頭像;3、通過(guò)一個(gè)字符串?dāng)?shù)組預(yù)置一些聊天語(yǔ)句,利用settimeout()函數(shù)定時(shí)通過(guò)Math.fllor(Math.random())方法進(jìn)行隨機(jī)讀取聊天語(yǔ)句,拼接上頭像文件在指定的ul li中顯示。同時(shí)記錄li的數(shù)量,在達(dá)到10條消息時(shí)清空ul中的內(nèi)容,并重置num變量為0。 -->

<!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>Chating_Room_Case</title>


<style>

* {


padding: 0;


margin: 0;


}


.mess {

width: 100%;

text-align: left;

}


ul li {


list-style: none;

padding: 4px;

line-height: 5px;

}


.container {


margin: 0 auto;


text-align: center;


margin: 15px;


}



.container .chatbox {


margin: 0 auto;


width: 300px;


height: 450px;


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>

<div class="mess">

<ul>


<li></li>


</ul>

</div>

</div>


<div>


<input type="text" placeholder="歡迎來(lái)到本聊天室......." class="msg"> <button class="btn">發(fā)送</button></div>


</div>


<script>


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


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


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

let num = 0;


button.onclick = function () {


if (input.value.length == 0) {

alert('hello,please talking');

return false;

}


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

let avandor = '<img src="https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=215857342,2013279815&fm=26&gp=0.jpg" style="width:30px;height:30px;border-radius:50%;">';

li.innerHTML = avandor + '  ' + input.value;

ul.appendChild(li);

input.value = '';

num += 1;


setTimeout(function () {


let msg = [


'hello,this is my chating room',

'Nani,what do you say?',

'I like drink orange juice',

'how do you do?'

];

let tmp = msg[Math.floor(Math.random() * 4)];

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

let repic = '<img src="https://ss2.bdstatic.com/70cFvnSh_Q1YnxGkpoWK1HF6hhy/it/u=2519058618,822923318&fm=26&gp=0.jpg" style="width:30px;height:30px;border-radius:50%;">';

reply.innerHTML = repic + ' ' + tmp;

ul.appendChild(reply);

num += 1;

}, 1000);


if (num > 10) {

ul.innerHTML = '';

num = 0;

}

}


</script>


</body>


</html>


Professeur correcteur:韋小寶Temps de correction:2019-03-09 13:29:25
Résumé du professeur:和上一篇作業(yè)基本上是一樣的 加了個(gè)總結(jié)描述 寫(xiě)的還是很不錯(cuò)的

Notes de version

Entrées populaires