可以添加、删除、编辑待办事项,或者设定提醒等html网页
时间: 2023-08-16 07:07:04 浏览: 40
好的,那么您可以使用HTML、CSS和JavaScript来创建这个待办事项网页。以下是一个简单的示例代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>待办事项</title>
<style>
body {
font-family: Arial, sans-serif;
}
h1 {
text-align: center;
}
form {
display: flex;
flex-direction: column;
align-items: center;
}
input[type=text] {
padding: 10px;
margin: 10px;
border-radius: 5px;
border: none;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
width: 300px;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
width: 300px;
margin-top: 10px;
}
ul {
list-style: none;
padding: 0;
margin-top: 20px;
width: 300px;
}
li {
padding: 10px;
border-radius: 5px;
border: none;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
margin-bottom: 10px;
display: flex;
justify-content: space-between;
align-items: center;
}
li span {
flex: 1;
}
li button {
background-color: #f44336;
color: white;
padding: 5px 10px;
border: none;
border-radius: 5px;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}
</style>
</head>
<body>
<h1>待办事项</h1>
<form>
<label for="newItem">添加新事项:</label>
<input type="text" id="newItem" placeholder="输入新事项">
<input type="submit" value="添加">
</form>
<ul id="list">
</ul>
<script>
const form = document.querySelector('form');
const input = document.querySelector('input');
const ul = document.querySelector('ul');
form.addEventListener('submit', function(e) {
e.preventDefault();
const text = input.value.trim();
if (text !== '') {
const li = document.createElement('li');
const span = document.createElement('span');
const button = document.createElement('button');
span.textContent = text;
button.textContent = '删除';
li.appendChild(span);
li.appendChild(button);
ul.appendChild(li);
input.value = '';
button.addEventListener('click', function() {
li.remove();
});
}
});
</script>
</body>
</html>
```
这是一个基本的待办事项网页,包括添加待办事项和删除待办事项的功能。您可以根据自己的需求进行修改和扩展。