How can I implement functionality in my HTML and JS files to save, read, and load values from local storage? Additionally, how can I automatically populate a list with these saved values and add a clear button for clearing the local storage?
let addToDoButton = document.getElementById('addToDo');
let toDoContainer = document.getElementById('toDoContainer');
let inputField = document.getElementById('inputField');
addToDoButton.addEventListener('click', function(){
var paragraph = document.createElement('p');
paragraph.classList.add('paragraph-styling');
paragraph.innerText = inputField.value;
toDoContainer.appendChild(paragraph);
inputField.value = "";
paragraph.addEventListener('click', function(){
paragraph.style.textDecoration = "line-through";
paragraph.style.color = "red";
})
paragraph.addEventListener('dblclick', function(){
toDoContainer.removeChild(paragraph);
})
})
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
<title>To Do List</title>
</head>
<body>
<label><h1>To Do List</h1></label>
<div class="container">
<input id="inputField" type="text" name="todo" id="todo">
<button id="addToDo">+</button>
<div class="to-dos" id="toDoContainer">
</div>
</div>
<script src="main.js"></scr
ipt>
</body>
</html>