abstrait:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>DOM實戰(zhàn)模擬智能在線客服系統(tǒng)</title><style> div:nth-child(1){ &nb
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>DOM實戰(zhàn)模擬智能在線客服系統(tǒng)</title>
<style>
div:nth-child(1){
width:400px;
height: 500px;
background: lightskyblue;
margin:30px auto;
color:#333;
box-shadow: 2px 2px 2px #808080;
}
h2 {
text-align: center;
margin-bottom: -10px;
}
div:nth-child(2){
width:300px;
height: 350px;
background: white;
margin:30px auto;
color:#333;
box-shadow: 2px 2px 2px #808080;
}
input {
width: 300px;
height: 40px
}
button {
width: 60px;
height: 40px;
background: white;
border: none;
}
button:hover{
background: orange;
cursor: pointer;
}
</style>
</head>
<body>
<div>
<h2>在線客服</h2>
<div>
<ul>
<li></li>
</ul>
</div>
<input type="text" name="info">
<button>發(fā)送</button>
</div>
<script>
//
let button = document.getElementsByTagname('button')[0];
let input = document.getElementsByName('info')[0];
let ul = document.getElementsByTagname('ul')[0];
button.onclick = function(){
let li = document.createElement('li');//創(chuàng)建LI標(biāo)簽
li.innerHTML = input.value;//文本框中的內(nèi)容傳至LI標(biāo)簽中
ul.appendChild(li);//將用戶信息顯示到列表
input.value = '';//清空文本框
}
</script>
</body>
</html>
Professeur correcteur:天蓬老師Temps de correction:2019-02-01 16:05:00
Résumé du professeur:是哪里不會了? 還有, js中的注釋, 盡可能寫在代碼的上面, 不要寫到右邊