请用html和css和javascript写一个备忘录
时间: 2023-03-07 18:22:56 浏览: 124
我可以写一个简单的备忘录,使用HTML、CSS和JavaScript:<html><head><title>备忘录</title><style>.container {
width: 500px;
margin: 0 auto;
font-family: sans-serif;
}ul {
padding: 0;
margin: 0;
}li {
list-style: none;
margin: 10px 0;
}input {
width: 100%;
padding: 10px;
margin-bottom: 10px;
font-size: 16px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box;
}</style></head><body><div class="container">
<h1>备忘录</h1>
<ul id="memoList">
</ul>
<input type="text" id="memoInput" placeholder="输入新备忘录">
</div><script>let memoInput = document.getElementById('memoInput');
let memoList = document.getElementById('memoList');memoInput.addEventListener('keydown', function(e) {
if (e.key === 'Enter') {
let newMemo = document.createElement('li');
newMemo.innerText = memoInput.value;
memoList.appendChild(newMemo);
memoInput.value = '';
}
});</script></body></html>