当前位置:网站首页>Todolist incomplete, completed
Todolist incomplete, completed
2022-06-26 03:22:00 【Small vegetable bird yard live】
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>storage</title>
</head>
<body>
<input type="text" required id="inp">
<h2> Hang in the air <span id="num">0</span></h2>
<ul id="list">
</ul>
<h2> Completed </h2>
<ul id="com">
</ul>
<script>
var inp = document.getElementById('inp');
var list = document.getElementById('list');
var com = document.getElementById('com');
if(localStorage.getItem('data')){
var todo = localStorage.getItem('data');
var arr = JSON.parse(todo);
var arr1 = [];
}else{
var arr = [];
var arr1 = [];
}
function init(){
list.innerHTML = '';
for(var i=0;i<arr.length;i++){
list.innerHTML += '<li index='+i+'><input type="checkbox">'+arr[i]+'<button> Delete </button></li>'
}// Encapsulate a function
}
init();
inp.onkeydown = function(e){
if(e.keyCode === 13){
arr.push(inp.value);
num.innerHTML = arr.length;
localStorage.setItem('data',JSON.stringify(arr));
list.innerHTML += '<li><input type="checkbox">'+inp.value+'<button> Delete </button></li>'
}
}
list.onclick = function(e){
if(e.target.nodeName==='INPUT'){
var idx = e.target.parentNode.getAttribute('index');
var last = arr.splice(idx,1)[0];
num.innerHTML = arr.length;
arr1.push(last);
// list.removeChild(e.target.parentNode);
init();
com.innerHTML += '<li><input checked type="checkbox">'+last+'<button> Delete </button></li>'
}
if(e.target.nodeName==='BUTTON'){
var idx = e.target.parentNode.getAttribute('index');
var last = arr.splice(idx,1)[0];
init();
}
}
// var arr = {name:123};
// localStorage.setItem('name',JSON.stringify(arr));
// var obj = JSON.parse(localStorage.getItem('name'));
// console.log(obj);
// localStorage.setItem('name','zhangsan');
</script>
</body>
</html>

边栏推荐
- 工业机器人之“慧眼”——机器视觉
- The "eye" of industrial robot -- machine vision
- Is it safe to open a fund account? How to apply
- Vulhub replicate an ActiveMQ
- Clion项目中运行多个main函数
- Stm32cubemx: watchdog ------ independent watchdog and window watchdog
- 360 秒了解 SmartX 超融合基础设施
- Plug in installation and shortcut keys of jupyter notebook
- Arduino string to hexadecimal number for large color serial port screen.
- Authorization of database
猜你喜欢

数字孪生智慧水务,突破海绵城市发展困境

Inkscape如何将png图片转换为svg图片并且不失真

Utonmos adheres to the principle of "collection and copyright" to help the high-quality development of traditional culture

Qt编译出错ERROR: Unknown module(s) in QT: script

学习太极创客 — MQTT(五)发布、订阅和取消订阅

论文回顾:Unmixing-Based Soft Color Segmentation for Image Manipulation

Group note data representation and operation check code

进度条

解析少儿编程的多元评价体系

The role of children's programming in promoting traditional disciplines in China
随机推荐
上传文件/文本/图片,盒子阴影
R language Markov chain Monte Carlo: practical introduction
学习太极创客 — MQTT(四)服务端连接操作
P2483-[模板]k短路/[SDOI2010]魔法猪学院【主席树,堆】
【哈希表】很简单的拉链法哈希结构,以至于效果太差,冲突太多,链表太长
Add console programs in UE
[hash table] improved, zipper hash structure - directly use two indexes to search, instead of hashing and% every time
国信金太阳靠谱吗?开证券账户安全吗?
USB driver -debug
Analysis of the multiple evaluation system of children's programming
[hash table] a very simple zipper hash structure, so that the effect is too poor, there are too many conflicts, and the linked list is too long
What can Arthas do for you?
Is it safe for individuals to buy stocks with flush software? How to buy stocks
丝网印刷的种类及其应用方法
论文回顾:Unmixing-Based Soft Color Segmentation for Image Manipulation
Google recommends using kotlin flow in MVVM architecture
【论文笔记】Learning to Grasp with Primitive Shaped Object Policies
网络PXE启动WinPE,支持UEFI和LEGACY引导
Drawing structure diagram with idea
【读点论文】FBNetV3: Joint Architecture-Recipe Search using Predictor Pretraining 网络结构和超参数全当训练参数给训练了