跟老师的代码一样

Original 2019-05-28 12:12:16 186
abstract:<!DOCTYPE html><html><head><meta charset="UTF-8"><title>热身:仿机器人聊天窗口</title></head><body><input type="text" name="info"&

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>热身:仿机器人聊天窗口</title>

</head>

<body>

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

<button>提交</button>

<ul>


</ul>

<script type="text/javascript">

//获取元素

var input = document.getElementsByName('info')[0];

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

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


button.onclick = function() {

var li = document.createElement('li'); // 创建列表项li

li.innerHTML = input.value; // 填充内容

ul.appendChild(li); //将内容添加到列表中

         input.value = ''; //清空文本框

};

</script>

</body>

</html>


Correcting teacher:天蓬老师Correction time:2019-05-28 15:57:04
Teacher's summary:看到了, 直接复制的课堂代码, 如果自己写能写出多少呢?

Release Notes

Popular Entries