dom聊天内容发送

Original 2019-05-10 15:49:58 1040
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>Document</title></head><body><input type="text" name="message"&

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Document</title>

</head>

<body>

<input type="text" name="message">

<button>提交</button>

<ul></ul>

</body>

<script type="text/javascript">

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

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

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


button.onclick = function(){

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

li.innerHTML = message.value;

ul.appendChild(li);

message.value="";

}

//1获取发送信息

//2创建信息列表

//3把信息添加到列表中

//4清空发送框内容

</script>

</html>


Correcting teacher:天蓬老师Correction time:2019-05-10 16:01:27
Teacher's summary:步骤是对的, 这个案例主要是考察你对dom常用方法的掌握

Release Notes

Popular Entries