当前位置:网站首页>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>
边栏推荐
- Google recommends using kotlin flow in MVVM architecture
- [solution] the blue screen restart problem of the virtual machine started by the VMware of Lenovo Savior
- 工作室第3次HarmonyOS培训笔记
- How to add a table to a drawing in ggplot2
- 【QT】自定义控件-空气质量仪表盘
- [reading papers] fbnetv3: joint architecture recipe search using predictor training network structure and super parameters are all trained by training parameters
- 【论文笔记】Deep Reinforcement Learning Control of Hand-Eye Coordination with a Software Retina
- 【论文笔记】Learning to Grasp with Primitive Shaped Object Policies
- Wealth freedom skills: commercialize yourself
- Leetcode 175 Combine two tables (2022.06.24)
猜你喜欢
Matlab| short term load forecasting of power system based on BP neural network
经典模型——AlexNet
Cultivate children's creativity under the concept of project steam Education
Good news | congratulations on the addition of 5 new committers in Apache linkage (incubating) community
Stm32cubemx: watchdog ------ independent watchdog and window watchdog
给网站添加“开放搜索描述“以适配浏览器的“站点搜索“
工业机器人之“慧眼”——机器视觉
《你不可不知的人性》经典语录
小米电视的网页和珠宝的网页
What can Arthas do for you?
随机推荐
[QT] custom control - switch
学习太极创客 — MQTT(五)发布、订阅和取消订阅
Classic quotations from "human nature you must not know"
Analysis on the diversification of maker space mechanism construction
Good news | congratulations on the addition of 5 new committers in Apache linkage (incubating) community
Kotlin quick start
渐变
Utonmos: digital collections help the inheritance of Chinese culture and the development of digital technology
HL7Exception: Can‘t XML-encode a GenericMessage. Message must have a recognized struct
MySQL增删查改(进阶)
Review of the paper: unmixing based soft color segmentation for image manipulation
I am in Zhongshan. Where can I open an account? Is it safe to open an account online?
GStreamer allocator and pool
[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
Route jump: click the operation button of the list to jump to another menu page and activate the corresponding menu
js array数组json去重
给网站添加“开放搜索描述“以适配浏览器的“站点搜索“
在哪里开基金帐户安全?
【QT】自定义控件-空气质量仪表盘
解析创客空间机制建设的多样化