Hello,
Here is my code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://kit.fontawesome.com/1f5460a8a6.js"></script>
<link rel="stylesheet" href="style.css">
<title>Todo List</title>
</head>
<body>
<div id="container">
<h1>To-do List</h1>
<input type="text">
<ul>
<li><span>X</span>Item 1</li>
<li><span>X</span>Item 2</li>
<li><span>X</span>Item 3</li>
</ul>
</div>
<script src="script.js"></script>
</body>
</html>
let span = document.querySelector("span");
let ul = document.querySelector("ul");
let li = document.querySelector("li");
//delete todos
span.addEventListener("click", function(event){
li.removeChild(span);
event.stopPropagation();
});
When the span tags are clicked, the X text should go away. By running the code I have, it is only removing the first span only, not the other two. I have tried switching the statement let li = document.querySelectorAll(“li”) to see if that would work, but no luck. How should I proceed to make this work?