国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

實(shí)戰(zhàn)熱身總結(jié)理解

Original 2019-08-09 12:52:41 240
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>DOM實(shí)戰(zhàn):模擬智能在線客服系統(tǒng)</title><style type="text/css">div:nth-child(1) {width: 450px;heig

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>DOM實(shí)戰(zhàn):模擬智能在線客服系統(tǒng)</title>

<style type="text/css">

div:nth-child(1) {

width: 450px;

height: 650px;

background-color: lightskyblue;

margin: 30px auto;

color: #333;

box-shadow: 2px 2px 2px #808080

}


h2 {

text-align: center;

margin-bottom: -10px;

}

div:nth-child(2) {

width: 400px;

height: 500px;

border: 4px double green;

background-color: #efefef;

margin: 20px auto 10px;

}


ul {

list-style: none;

line-height: 2em;

/*border: 1px solid red;*/

overflow: hidden;

padding: 15px;

}


table {

width: 90%;

height:80px;

margin: auto;

}


textarea{

/*width: 300px;*/

border: none;

resize: none;

background-color: lightyellow;


}

button {

width: 60px;

height: 40px;

background-color: seagreen;

color: white;

border: none;

/*text-align: left;*/


}

button:hover {

cursor: pointer;

background-color: orange;

}

</style>

</head>

<body>

<div>

<h2>在線客服</h2>

<div contenteditable="true">

<ul>

<li></li>

</ul>

</div>

<table>

<tr>

<td><textarea cols="50" rows="4" name="text"></textarea></td>

<td><button type=button>發(fā)送</button></td>

</tr>

</table>

</div>

<script type="text/javascript">

//獲取到頁面中的按鈕,文本域,對(duì)話內(nèi)容區(qū)

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

let text = document.getElementsByName('text')[0];

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

let sum = 0;


//添加按鈕點(diǎn)擊事件,獲取用戶數(shù)據(jù)并推送到對(duì)話窗口中

btn.onclick = function () {

// alert(text.value)

//獲取用戶提交的內(nèi)容

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

alert('客官:是不是忘記輸入內(nèi)容了~~');

return false;

}

let userComment = text.value;


//立即清空用戶信息區(qū)

text.value = '';


//創(chuàng)建一個(gè)新節(jié)點(diǎn)li

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

li.innerHTML = userComment;  //將用戶輸入的內(nèi)容添加到新節(jié)點(diǎn)中

let userPic = '<img src="inc/peter.jpg" width="30" style="border-radius:50%">'; // 設(shè)置用戶頭像

li.innerHTML = userPic + ' ' + userComment; // 將用戶頭像與用戶的聊天內(nèi)容合并

list.appendChild(li); //發(fā)送聊天內(nèi)容,實(shí)際上就是將新節(jié)點(diǎn)插入到對(duì)話列表中

sum += 1; // 聊天記錄自增1


//設(shè)置定時(shí)器,默認(rèn)2秒后會(huì)自動(dòng)回復(fù)

setTimeout(function(){

let info = [

    '真煩人,有話快說,別耽誤我玩抖音',

'除了退貨,退款,咱們什么都可以聊',

'說啥,本姑娘怎么聽不懂呢?再說一遍',

'在我方便的時(shí)候再回復(fù)你吧~~',

'投訴我的人多了,你算老幾~~~'

];

let temp = info[Math.floor(Math.random()*3)];

//取1-5之間的一個(gè)整數(shù):Math.floor(Math.random()*6 + 1)

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

let kefuPic = '<img src="inc/zly.jpg" width="30" style="border-radius:50%;">';

// reply.innerHTML = '你有啥事呀,我的帥哥哥' +kefuPic

reply.innerHTML = kefuPic + ' ' + '<span style="color:red">'+temp+'</span>';


list.appendChild(reply);

sum += 1;


},2000);


// 當(dāng)聊天記錄達(dá)到10條時(shí)清空窗口

if (sum > 10) {

list.innerHTML = '';

sum = 0;

}

}



</script>

</body>

</html>


Correcting teacher:天蓬老師Correction time:2019-08-15 10:42:42
Teacher's summary:你的總結(jié)與理解的內(nèi)容呢, 除了代碼沒有看到其它 這幾個(gè)作業(yè)不要分開, 應(yīng)該放在一起提交

Release Notes

Popular Entries