<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
<style>
li {
list-style-type: none;
border-radius: 20px;
height: 40px;
margin: 10px;
padding-left: 20px;
font-size: 20px;
background-color: aliceblue;
position: relative;
}
li .bi-trash {
position: absolute;
right: 40px;
color: red;
cursor: pointer;
}
.st {
text-decoration: line-through;
}
.bi-x-circle {
font-size: 20px;
color: red;
cursor: pointer;
margin-left: 10px;
}
</style>
</head>
<body>
<div class="card mx-auto" style="width: 30rem; padding-bottom: 20px;">
<div class="card-header bg-success text-white text-center">
<h1>Works to-dos</h1>
</div>
<div class="card-body text-center">
<p>Enter text into the input field to add items to your list.</p>
<p>Click the item to mark it as complete.</p>
<p>Click the "X" to remove the item from your list.</p>
<p>Add Task: <input type="text" name="name" id="txttask" style="border: solid 2px; border-radius: 20px;">
<button class="btn btn-primary" style="border-radius: 20px;" id="addtask">Add</button>
<i class="bi bi-x-circle" id="cleartasks"></i>
</p>
<ul id="container"></ul>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('container').addEventListener('click', function(event) {
if (event.target.tagName === 'SPAN') {
event.target.classList.toggle('st');
} else if (event.target.classList.contains('bi-trash')) {
event.target.parentElement.remove();
}
});
document.getElementById('addtask').addEventListener('click', function() {
var taskText = document.getElementById('txttask').value;
if (taskText) {
var li = document.createElement('li');
var span = document.createElement('span');
span.textContent = taskText;
var trashIcon = document.createElement('i');
trashIcon.classList.add('bi', 'bi-trash');
li.appendChild(span);
li.appendChild(trashIcon);
document.getElementById('container').appendChild(li);
document.getElementById('txttask').value = ''; // Clear the input field after adding the task
}
});
document.getElementById('cleartasks').addEventListener('click', function() {
document.getElementById('container').innerHTML = '';
});
});
</script>
</body>
</html>
js's Introduction
js's People
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.