<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="style.css" rel="stylesheet">
<script src="https://kit.fontawesome.com/e07554ba7b.js" crossorigin="anonymous"></script>
</head>
<body>
<h1 class="main_title">todo list</h1>
<div class="theme">
<p class="change_theme_text">dark mode</p>
<i class="theme_icon fas fa-moon"></i>
</div>
<div class="flex_conainer" >
<div class="input_container">
<p class="input_title">+ add new to do ; </p>
<form class="form">
<input class="input_text" type="text" placeholder="new todo . . . " >
<button class="input_btn" class="far fa-plus-square"> add</button>
</form>
</div>
<div class="todo_container">
<ul class="todo_ul">
<li class="todo_li"><i class="check_icon fas fa-paperclip"></i><span class="todo_span">learn js</span><i class="icon far fa-trash-alt"></i></li>
<li class="todo_li"><i class="check_icon fas fa-paperclip"></i><span class="todo_span">learn React</span><i class="icon far fa-trash-alt"></i></li>
<li class="todo_li"><i class="check_icon fas fa-paperclip"></i><span class="todo_span">learn vue</span><i class="icon far fa-trash-alt"></i></li>
</ul>
</div>
</div>
<script src="./script.js"></script>
</body>
</html>
let $ = document;
let themeBtn = $.querySelector(".theme_icon");
let changeThemeTtext = $.querySelector(".change_theme_text");
let addBtn = $.querySelector(".input_btn");
let inputTitle = $.querySelector(".input_title");
let inputElem = $.querySelector(".input_text");
let todo_ul = $.querySelector(".todo_ul");
let form = $.querySelector(".form");
let dayFlag = true;
function addTodo(newTodoValue) {
let newLi = $.createElement("li");
newLi.className = "todo_li";
let newSpan = $.createElement("span");
newSpan.className = "todo_span";
newSpan.innerText = newTodoValue ;
let newBeforIcon = $.createElement("i");
newBeforIcon.className = "check_icon fas fa-paperclip";
let newTrashIcon = $.createElement("i");
newTrashIcon.className = "icon far fa-trash-alt";
newLi.append(newBeforIcon, newSpan , newTrashIcon);
todo_ul.append(newLi);
console.log(newLi);
}
form.addEventListener("submit", function (event) {
event.preventDefault();
});
themeBtn.addEventListener("click", function () {
if (dayFlag) {
$.body.style.backgroundImage = "url(https://pngtree.com/freebackground/halloween-haunted-house-night-background_1221299.html)";
dayFlag = false;
changeThemeTtext.innerHTML = "light mode";
changeThemeTtext.style.color = "yellow";
themeBtn.setAttribute("class", "sun_icon fas fa-sun");
inputTitle.style.color = "#ff8300";
} else {
themeBtn.setAttribute("class", "theme_icon fas fa-moon");
inputTitle.style.color = "black";
changeThemeTtext.style.color = "black";
dayFlag = true;
$.body.style.backgroundImage = "url(https://pngtree.com/freebackground/hand-painted-green-childrens-day-background-design_938775.html)";
}
});
inputElem.addEventListener("keydown", function (event) {
let newTodoValue = event.target.value.trim();
if (event.keyCode === 13) {
if (newTodoValue) {
inputElem.value = "";
addTodo();
console.log(newTodoValue);
}
}
});
Output
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |