overlordofmc
New Coder
So I took coding as a subject (year 10) as I was interested. Only problem is that I haven't got much coding experience and my project was due two days ago. I need help with making 3 lists I can add and remove items to and from. I also need to customise them using CSS. I'm not sure at all how to do this and just some help would be great. Here's the code I got from the slides presented in class:
HTML:
<!DOCTYPE html>
<html>
<head>
<title>To-Do List App</title>
<script>
function addItem () {
var newitem = document.createElement(“div”)
newItem.innerHTML = document.getElementById(“typedItem”).value;
newItem.onclick = removeItem;
document.getElementById(“list”).appendChild(newItem);
saveList();
}
function removeItem() {
document.getElementById(“list”).removeChild(this);
saveList():
}
functionsaveList() {
localStorage.storedList = document.getElementById("list").innerHTML;
}
function loadList()
document.getElementById(“list”).innerHTML=localStorage.storedList;
for(var i = 0; i <list.children.length; i++) {
list.children.onclick = removeItem
}
}
</script>
</head>
<body>
<p>Explorer’s Packing LIst</p>
<br/>
<input type=“text” id=“typedItem” value=“Type in a new item”/>
<br/>
<input type=“button” value=“Add new item” onclick=“addItem();”/>
<br/>
<div id=“list”></div>
<script>
if(localStorage.storedList) {
loadList();
}
</script>
</body>
</html>
Last edited by a moderator: