Nodejs đang tung ra version 17. 0. 1 có nhiều tính năng được cải tiến. Nếu ai đang sử dụng phiên bản nodejs và đang sử dụng Mac thì nếu muốn nâng cấp lên thì có thể tham khảo 3 cách dưới đây
Dưới đây là một số cách thay thế để cập nhật phiên bản mới nhất của Node. js trên máy Mac của bạn
cập nhật nút bằng nvm
nvm viết tắt là
html,
body {
margin: 0;
padding: 0;
font-family: "Roboto", sans-serif;
--text-color: #333;
color: var[--text-color];
background-color: #e0f0fd;
}
.container {
text-align: center;
width: 40%;
margin: auto;
color: #181818;
min-height: 90vh;
margin-top: 2%;
}
.todo {
width: 100%;
padding-bottom: 15px;
background: #3366ff;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
color: #ffffff;
}
h1 {
margin-bottom: 20px;
font-size: 80px;
margin-top: 0;
padding-left: 10px;
}
input {
background: none;
outline: none;
border: none;
border-bottom: 2px solid #ffffff;
color: #ffffff;
padding: 8px;
font-size: 20px;
}
.list-todo {
height: 60vh;
background-color: #ffffff;
overflow-x: scroll;
}
#todo {
padding: 0 10px 0 10px;
}
#todo li {
list-style: none;
font-size: 16px;
width: 100%;
max-width: 100%;
display: flex;
--webkit-display: flex;
align-items: flex-start;
justify-content: space-between;
text-align: justify;
margin-bottom: 15px;
border-bottom: 1px solid #777777;
padding-bottom: 8px;
}
#todo li.completed {
text-decoration: line-through;
}
#todo li.uncompleted {
text-decoration: none;
color: black;
}
#todo li input {
margin-right: 10px;
}
#todo li button {
outline: none;
border: none;
border-radius: 200px;
margin-left: 10px;
background-color: #3366ff;
color: #ffffff;
width: 6%;
height: 5vh;
}
9 nhìn sơ qua cũng biết nó làm gì rồi. Nó có sẵn trên html,
body {
margin: 0;
padding: 0;
font-family: "Roboto", sans-serif;
--text-color: #333;
color: var[--text-color];
background-color: #e0f0fd;
}
.container {
text-align: center;
width: 40%;
margin: auto;
color: #181818;
min-height: 90vh;
margin-top: 2%;
}
.todo {
width: 100%;
padding-bottom: 15px;
background: #3366ff;
border-top-left-radius: 20px;
border-top-right-radius: 20px;
color: #ffffff;
}
h1 {
margin-bottom: 20px;
font-size: 80px;
margin-top: 0;
padding-left: 10px;
}
input {
background: none;
outline: none;
border: none;
border-bottom: 2px solid #ffffff;
color: #ffffff;
padding: 8px;
font-size: 20px;
}
.list-todo {
height: 60vh;
background-color: #ffffff;
overflow-x: scroll;
}
#todo {
padding: 0 10px 0 10px;
}
#todo li {
list-style: none;
font-size: 16px;
width: 100%;
max-width: 100%;
display: flex;
--webkit-display: flex;
align-items: flex-start;
justify-content: space-between;
text-align: justify;
margin-bottom: 15px;
border-bottom: 1px solid #777777;
padding-bottom: 8px;
}
#todo li.completed {
text-decoration: line-through;
}
#todo li.uncompleted {
text-decoration: none;
color: black;
}
#todo li input {
margin-right: 10px;
}
#todo li button {
outline: none;
border: none;
border-radius: 200px;
margin-left: 10px;
background-color: #3366ff;
color: #ffffff;
width: 6%;
height: 5vh;
}
0 hoặc có thể cài đặt nếu muốn. Nếu bạn đã cài đặt nvm thành công rồi thì bạn muốn cập nhật phiên bản nodejs lên thì có thể thực hiện theo các bước sau Lưu ý mệnh đề WHERE trong cú pháp UPDATE. Mệnh đề WHERE only the write-type or the write to have been update or. Nếu bạn bỏ qua mệnh đề WHERE, tất cả các bản ghi sẽ được cập nhật
Save code on file has name "demo_db_update. js" and run file
C. \Users\Tên của bạn>nút demo_db_update. js
Kết quả
1 bản ghi được cập nhật
Kết quả đối tượng
Khi thực hiện một truy vấn, một kết quả đối tượng được trả về
Đối tượng kết quả chứa thông tin về cách truy vấn ảnh hưởng đến bảng
Kết quả đối tượng trả về từ ví dụ trông giống như sau
{
trườngCount. 0,
bị ảnh hưởngRows. 1,
insertId. 0,
Trạng thái máy chủ. 34,
warningCount. 0,
thông báo. '[Các hàng khớp. 1 đã thay đổi. 1 cảnh báo. 0',
giao thức41. true,
đã thay đổiRows. 1
}
Truy cập vào thuộc tính của đối tượng kết quả ta sử dụng toán tử [ . ].
Ví dụ nếu ta muốn truy cập các thuộc tính bị ảnh hưởngRows để biết số lượng cột chịu ảnh hưởng từ câu lệnh truy vấn thì ta làm như sau
Java Scrip có rất nhiều tác dụng như tạo hiệu ứng cho trang web, tạo cửa sổ bật lên quảng cáo, ngăn chặn người dùng tải dữ liệu từ trang web… Tuy nhiên, ngoài mặt hữu ích ứng dụng của nó cũng gây ra một số phiền phức. Không giới hạn khi bạn muốn lưu 1 ảnh mà bạn thích từ một trang web nhưng khi nhấp chuột phải vào ảnh đó lại không thấy tác dụng, không thấy phần Lưu ảnh. Vì thế bài viết này mình sẽ hướng dẫn các bạn cách tắt Java Scrip. Tuy nhiên, sau khi hoàn thành công việc bạn muốn, hãy mở lại Java Scrip để khi vào các trang web chứa nhiều Java Scrip, trình duyệt mới sẽ hiển thị hết nội dung trang web.Google Chrome [Tiếng Việt]
Nhập vào thanh địa chỉ của Chrome chrome. //settings/content rồi Enter
Sau đó lựa chọn việc tắt hoặc mở JavaScript
- Để bật JavaScript chọn Cho phép .
- Để tắt tùy chọn Javascrip còn lại Không cho phép bất kỳ trang web nào chạy JavaScript
Chọn xong thì nhấp vào Hoàn tất
Mozilla Firefox
Trên thành địa chỉ gõ about:config rồi Enter
Click vào "Tôi sẽ cẩn thận. tôi hứa. "
Sau đó bạn tìm thấy trong danh sách giá trị đó có tên là javascript. đã bật => Nháy kép vào nó để biến giá trị True thành False là Java Script sẽ tắt. Sau khi hoàn thành công việc, bạn lặp lại các bước như trên để mở lại Java Script
Internet Explorer [9. 0]
Ấn Alt nếu chưa hiện Menu bar
- Select Tools [Công cụ] từ menu trên cùng.
- Select Internet Options [Tùy chọn Internet]
- Lướt vào tab Security [Bảo mật]
- Lật vào Cấp độ tùy chỉnh [Cấp độ tùy chỉnh]
- Cuộn xuống cho đến khi bạn thấy mục có gắn nhãn 'Scripting'
- Trong 'Active Scripting', để bật JavaScript chọn Bật [Bật] và để tắt tùy chọn Javascript chọn quay lại
Trong hướng dẫn này, chúng ta sẽ xem xét cách tạo một ứng dụng Crud bằng JavaScript. Chúng ta sẽ tạo một ứng dụng có tên Todo. Nó tập trung nhiều hơn vào những người mới học javascript. Đơn giản ứng dụng là biến phổ biến nhất để xây dựng khi học một ngôn ngữ lập trình mới. Chúng ta cùng bắt đầu
Yêu cầu
Bạn cần phải có kiến thức cơ bản về Biến, Mảng, Hàm và Đối tượng trước khi bắt đầu theo hướng dẫn của bài viết này
Kết quả
Ở trong hướng dẫn này, bạn có thể làm được các công việc sau
- Thêm nhiệm vụ mới
- Đánh dấu 1 nhiệm vụ đã hoàn thành
- Xóa một nhiệm vụ đã được thêm mới thành công
Tạo giao diện người dùng
Chúng ta sẽ bắt đầu bằng cách xây dựng giao diện người dùng. Đầu tiên chúng ta cần tạo một tệp
2 mà chúng ta sẽ viết tất cả các mã htmlhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
To Do List
Todo
What do you want to get done today?
Trong đoạn mã trên là thẻ
3html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
4 và thẻhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
5 với class="container". Bên tronghtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
5 chúng ta có một thẻhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
7 và một thẻhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
8. Thehtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
7 có các phần tử đầu vào. tywr tywr đầu vào cóhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
0 cái mà chúng ta sẽ sử dụng để nhận giá trị đầu vào của người dùng. Thẻconst form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
8 nơi chúng ta hiển thị giá tri người dùng nhập vào sau khi nhấn núthtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
2 Chúng ta sẽ tạo kiểu cho html để ứng dụng. Tạo tệp. css and link it to the body of file. htmlconst form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
Thêm một nhiệm vụ
Chúng ta sẽ tạo 1 tệp. js and link it to the body of file. tệp html. js chúng ta sẽ viết mã sẽ kích hoạt thẻ đầu vào để gửi giá trị bất kỳ khi bất kỳ người dùng nào sử dụng thêm nhiệm vụ
const form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
Trong đoạn mã trên chúng ta đã khai báo một vài biến hằng số biên snayf có thể sử dụng ở bất kỳ đâu trong tệp. js Thuộc tính
3 là một phương thức trả về thành phần có thuộc tínhconst form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
4. Bạn có thể thấy rằng tất cả các mã chung ta tạo ra đều có mộtconst form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
4 cụ thể.const form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
6 gửi giá trị sau khi người dùng nhấn nútconst form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
2const form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
8 Ngừng công việc tải lại trang khi người dùng nhấn nútconst form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
2 để gửiconst form = document.getElementById["form"]; const input = document.getElementById["input"]; const button = document.getElementById["button"]; const todo = document.getElementById["todo"]; let todoList = []; form.addEventListener["submit", function [e] { e.preventDefault[]; addTodo[]; }]; function addTodo[] { // get input const newTodo = input.value; // return if nothing was entered if [!newTodo] return; // add the new task to todo list todoList.push[{ text: newTodo, completed: false, }]; // add the todo list to localstorage localStorage.setItem["todos", JSON.stringify[todoList]]; // render todo list render[]; }
7 chúng ta sẽ gọi chức năng addTodo[]html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
Chúng ta sẽ tạo hàm addTodo[] chúng ta sẽ gọi nó mỗi khi người dùng thêm tác vụ mới. Trong hàm chúng ta đã khai báo một biến newTodo là hằng số được gnas value là
21. Biến này chỉ có truy cập trong chức năng vì nó là biến cục bộhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
Chúng ta sẽ lưu trữ mảng trong
22 để chúng ta vẫn có thể truy cập giá trị bất kỳ lúc nàohtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
Đánh dấu một nhiệm vụ là đã hoàn thành
2html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
Chúng ta đã tạo một hàm khác
23. Trong hàmhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
23, trước tiên chúng ta sẽ xóa thẻ đầu vào sau khi người dùng thêm tác vụ. Chúng ta cũng lấy giá trị mà chúng ta đã lưu trữ trong localStorage và lặp qua giá trị này. Tạo thẻ ________ 225, ________ 226 và đặt loại đầu vào là hộp kiểm. Để kiểm tra xem nó đã được kiểm tra hay không, chúng tôi sẽ bổ sung thêm sự kiện kích hoạt khi hộp kiểm được chọn. Kiểu đánh giá đầu vào sẽ có giá trị làhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
27 khi chọn nó sẽ trả vềhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
28 và ngược lại trả vềhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
29 và chúng ta sẽ lưu trữ chúng vàohtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
22html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
31 điều kiện chạy khi người dùng chọn hộp kiểm hoặc bỏ chọn sổ kiểmhtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
Xóa một nhiệm vụ đã thêm
3html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
Tuy nhiên, bên cạnh hàm
23, chúng ta có một thẻ P để giữ văn bản và hiển thị lên sau khi người thêm tác vụ mới. Chúng ta tạo một nút thẻ và thêm văn bản bên trong “x” của nó và chúng tôi muốn khi người dùng nhấp vào nút, nó sẽ xóa một tác vụ đã hoàn thành hoặc bất kỳ tác vụ nào. Chúng ta đã bổ sung thêm xử lý sự kiện để kích hoạt nút "x" bất kể khi nào sự kiện nhấp chuột được thực hiện.html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
33 xóa một nhiệm vụ tacsk từ localStorage và sau đó, chúng sẽ chạy lại chức nănghtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
7html, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }
34 kết nối tất cả các phần tử Html mà chúng tôi đã tạo vào DOM và cũng thu hồi sau đó có thứ tự như hình bên dướihtml, body { margin: 0; padding: 0; font-family: "Roboto", sans-serif; --text-color: #333; color: var[--text-color]; background-color: #e0f0fd; } .container { text-align: center; width: 40%; margin: auto; color: #181818; min-height: 90vh; margin-top: 2%; } .todo { width: 100%; padding-bottom: 15px; background: #3366ff; border-top-left-radius: 20px; border-top-right-radius: 20px; color: #ffffff; } h1 { margin-bottom: 20px; font-size: 80px; margin-top: 0; padding-left: 10px; } input { background: none; outline: none; border: none; border-bottom: 2px solid #ffffff; color: #ffffff; padding: 8px; font-size: 20px; } .list-todo { height: 60vh; background-color: #ffffff; overflow-x: scroll; } #todo { padding: 0 10px 0 10px; } #todo li { list-style: none; font-size: 16px; width: 100%; max-width: 100%; display: flex; --webkit-display: flex; align-items: flex-start; justify-content: space-between; text-align: justify; margin-bottom: 15px; border-bottom: 1px solid #777777; padding-bottom: 8px; } #todo li.completed { text-decoration: line-through; } #todo li.uncompleted { text-decoration: none; color: black; } #todo li input { margin-right: 10px; } #todo li button { outline: none; border: none; border-radius: 200px; margin-left: 10px; background-color: #3366ff; color: #ffffff; width: 6%; height: 5vh; }